Skip to content

Commit

Permalink
Merge branch 'dev/deprecations' of github.com:googleapis/gapic-genera…
Browse files Browse the repository at this point in the history
…tor-python into dev/deprecations
  • Loading branch information
miraleung committed May 13, 2021
2 parents 69a0504 + ad62b27 commit 44e9c5b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

### [0.46.2](https://www.github.com/googleapis/gapic-generator-python/compare/v0.46.1...v0.46.2) (2021-05-12)


### Bug Fixes

* fix incorrectly referenced exceptions, add missing port to tests ([#873](https://www.github.com/googleapis/gapic-generator-python/issues/873)) ([40078c4](https://www.github.com/googleapis/gapic-generator-python/commit/40078c46b21a0dfa489d4cd80ed7d95bb542f3c3)), closes [#872](https://www.github.com/googleapis/gapic-generator-python/issues/872)

### [0.46.1](https://www.github.com/googleapis/gapic-generator-python/compare/v0.46.0...v0.46.1) (2021-05-07)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class {{ service.name }}Transport(metaclass=abc.ABCMeta):
{% if method.retry.backoff_multiplier %}multiplier={{ method.retry.backoff_multiplier }},{% endif %}
predicate=retries.if_exception_type(
{% for ex in method.retry.retryable_exceptions|sort(attribute='__name__') %}
exceptions.{{ ex.__name__ }},
core_exceptions.{{ ex.__name__ }},
{% endfor %}
),
deadline={{ method.timeout }},
Expand Down
8 changes: 4 additions & 4 deletions gapic/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_response(
sample_templates, client_templates = utils.partition(
lambda fname: os.path.basename(
fname) == samplegen.DEFAULT_TEMPLATE_NAME,
self._env.loader.list_templates(),
self._env.loader.list_templates(), # type: ignore
)

# Iterate over each template and add the appropriate output files
Expand All @@ -113,7 +113,7 @@ def get_response(
sample_output = self._generate_samples_and_manifest(
api_schema, self._env.get_template(sample_templates[0]),
opts=opts,
)
)
output_files.update(sample_output)

# Return the CodeGeneratorResponse output.
Expand Down Expand Up @@ -286,10 +286,10 @@ def _render_template(
for service in api_schema.services.values():
if (
(skip_subpackages
and service.meta.address.subpackage != api_schema.subpackage_view)
and service.meta.address.subpackage != api_schema.subpackage_view)
or
('transport' in template_name
and not self._is_desired_transport(template_name, opts))
and not self._is_desired_transport(template_name, opts))
or
# TODO(yon-mg) - remove when rest async implementation resolved
# temporarily stop async client gen while rest async is unkown
Expand Down
10 changes: 5 additions & 5 deletions gapic/schema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ def __str__(self) -> str:
if self.module:
module_name = self.module

# If collisions are registered and conflict with our module,
# use the module alias instead.
if self.module_alias:
module_name = self.module_alias

# This module is from a different proto package
# Most commonly happens for a common proto
# https://pypi.org/project/googleapis-common-protos/
if not self.proto_package.startswith(self.api_naming.proto_package):
module_name = f'{self.module}_pb2'

# If collisions are registered and conflict with our module,
# use the module alias instead.
if self.module_alias:
module_name = self.module_alias

# Return the dot-separated Python identifier.
return '.'.join((module_name,) + self.parent + (self.name,))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class {{ service.async_client_name }}:
{% if method.retry.backoff_multiplier %}multiplier={{ method.retry.backoff_multiplier }},{% endif %}
predicate=retries.if_exception_type(
{% for ex in method.retry.retryable_exceptions|sort(attribute="__name__") %}
exceptions.{{ ex.__name__ }},
core_exceptions.{{ ex.__name__ }},
{% endfor %}
),
deadline={{ method.timeout }},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ def test_{{ service.name|snake_case }}_transport_create_channel_old_api_core(tra

{% with host = (service.host|default('localhost', true)) %}
create_channel.assert_called_with(
"{{ host }}",
"{{ host }}{% if ":" not in service.host %}:443{% endif %}",
credentials=creds,
credentials_file=None,
quota_project_id="octopus",
Expand Down Expand Up @@ -1703,7 +1703,7 @@ def test_{{ service.name|snake_case }}_transport_create_channel_user_scopes(tran
transport_class(quota_project_id="octopus", scopes=["1", "2"])

create_channel.assert_called_with(
"{{ host }}",
"{{ host }}{% if ":" not in service.host %}:443{% endif %}",
credentials=creds,
credentials_file=None,
quota_project_id="octopus",
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
click==7.1.2
click==8.0.0
google-api-core==1.26.3
googleapis-common-protos==1.53.0
jinja2==2.11.3
MarkupSafe==1.1.1
jinja2==3.0.0
MarkupSafe==2.0.0
protobuf==3.16.0
pypandoc==1.5
PyYAML==5.4.1
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/schema/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ def test_address_str_different_proto_package():
assert str(addr) == 'options_pb2.GetPolicyOptions'


def test_address_str_different_proto_package_with_collision():
addr = metadata.Address(
package=('google', 'rpc'),
module='status',
name='Status',
api_naming=naming.NewNaming(proto_package='foo.bar.baz.v1')
).with_context(collisions=frozenset({'status'}))
# the module alias should be ignored for _pb2 types
assert str(addr) == 'status_pb2.Status'


def test_address_proto():
addr = metadata.Address(package=('foo', 'bar'), module='baz', name='Bacon')
assert addr.proto == 'foo.bar.Bacon'
Expand Down

0 comments on commit 44e9c5b

Please sign in to comment.