Skip to content

Commit

Permalink
fix: drop pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Dec 5, 2022
1 parent 5b98659 commit cf20316
Show file tree
Hide file tree
Showing 36 changed files with 89 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ from collections import OrderedDict
import functools
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, {% if service.any_server_streaming %}AsyncIterable, Awaitable, {% endif %}{% if service.any_client_streaming %}AsyncIterator, {% endif %}Sequence, Tuple, Type, Union
import pkg_resources
{% if service.any_deprecated %}
import warnings
{% endif %}

{% set package_path = api.naming.module_namespace|join('.') + "." + api.naming.versioned_module_name %}
from {{package_path}} import gapic_version as package_version

from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
Expand Down Expand Up @@ -676,14 +678,7 @@ class {{ service.async_client_name }}:
async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"{{ api.naming.warehouse_package_name }}",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import functools
import os
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, {% if service.any_server_streaming %}Iterable, {% endif %}{% if service.any_client_streaming %}Iterator, {% endif %}Sequence, Tuple, Type, Union, cast
import pkg_resources
{% if service.any_deprecated %}
import warnings
{% endif %}

{% set package_path = api.naming.module_namespace|join('.') + "." + api.naming.versioned_module_name %}
from {{package_path}} import gapic_version as package_version

from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
{% if service.any_extended_operations_methods %}
Expand Down Expand Up @@ -685,14 +687,8 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
# Done; return the response.
return response
{% endif %}
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"{{ api.naming.warehouse_package_name }}",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import pkg_resources

{% set package_path = api.naming.module_namespace|join('.') + "." + api.naming.versioned_module_name %}
from {{package_path}} import gapic_version as package_version

import google.auth # type: ignore
import google.api_core
Expand Down Expand Up @@ -39,14 +41,7 @@ from {{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + ser
{% endfor %}
{% endfilter %}

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
'{{ api.naming.warehouse_package_name }}',
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


class {{ service.name }}Transport(abc.ABC):
Expand Down
5 changes: 0 additions & 5 deletions gapic/templates/.coveragerc.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
2 changes: 1 addition & 1 deletion gapic/templates/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def cover(session):
@nox.session(python=ALL_PYTHON)
def mypy(session):
"""Run the type checker."""
session.install('mypy', 'types-pkg_resources')
session.install('mypy')
session.install('.')
session.run(
'mypy',
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/goldens/asset/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import functools
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.cloud.asset_v1 import version as package_version

from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -1679,14 +1680,7 @@ async def __aenter__(self):
async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-asset",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import os
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast
import pkg_resources

from google.cloud.asset_v1 import version as package_version

from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -1850,14 +1851,8 @@ def __exit__(self, type, value, traceback):



try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-asset",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import pkg_resources

from google.cloud.asset_v1 import version as package_version

import google.auth # type: ignore
import google.api_core
Expand All @@ -30,14 +31,7 @@
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
'google-cloud-asset',
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


class AssetServiceTransport(abc.ABC):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/goldens/asset/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def cover(session):
@nox.session(python=ALL_PYTHON)
def mypy(session):
"""Run the type checker."""
session.install('mypy', 'types-pkg_resources')
session.install('mypy')
session.install('.')
session.run(
'mypy',
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/goldens/credentials/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import functools
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.iam.credentials_v1 import gapic_version as package_version

from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -797,14 +798,7 @@ async def __aenter__(self):
async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-iam-credentials",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import os
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast
import pkg_resources

from google.iam.credentials_v1 import gapic_version as package_version

from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -975,14 +976,8 @@ def __exit__(self, type, value, traceback):



try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-iam-credentials",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import pkg_resources

from google.iam.credentials_v1 import gapic_version as package_version

import google.auth # type: ignore
import google.api_core
Expand All @@ -27,14 +28,7 @@

from google.iam.credentials_v1.types import common

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
'google-iam-credentials',
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


class IAMCredentialsTransport(abc.ABC):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/goldens/credentials/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def cover(session):
@nox.session(python=ALL_PYTHON)
def mypy(session):
"""Run the type checker."""
session.install('mypy', 'types-pkg_resources')
session.install('mypy')
session.install('.')
session.run(
'mypy',
Expand Down
5 changes: 0 additions & 5 deletions tests/integration/goldens/eventarc/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import functools
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union
import pkg_resources

from google.cloud.eventarc_v1 import gapic_version as package_version

from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -827,14 +828,7 @@ async def __aenter__(self):
async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-eventarc",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import os
import re
from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast
import pkg_resources

from google.cloud.eventarc_v1 import gapic_version as package_version

from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -1051,14 +1052,8 @@ def __exit__(self, type, value, traceback):



try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-eventarc",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


__all__ = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import pkg_resources

from google.cloud.eventarc_v1 import gapic_version as package_version

import google.auth # type: ignore
import google.api_core
Expand All @@ -30,14 +31,7 @@
from google.cloud.eventarc_v1.types import trigger
from google.longrunning import operations_pb2 # type: ignore

try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
'google-cloud-eventarc',
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(package_version.__version__)


class EventarcTransport(abc.ABC):
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/goldens/eventarc/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def cover(session):
@nox.session(python=ALL_PYTHON)
def mypy(session):
"""Run the type checker."""
session.install('mypy', 'types-pkg_resources')
session.install('mypy')
session.install('.')
session.run(
'mypy',
Expand Down
Loading

0 comments on commit cf20316

Please sign in to comment.