Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 9046261

Browse files
authored
fix: fix syntax errors and failing unit tests (#849)
Fixes #848
1 parent 5929070 commit 9046261

9 files changed

Lines changed: 31 additions & 33 deletions

File tree

gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
305305
{% if not method.client_streaming %}
306306
request (:class:`{{ method.input.ident.sphinx }}`):
307307
The request object.{{ ' ' }}
308-
{{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
308+
{{- method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
309309
{% for key, field in method.flattened_fields.items() %}
310310
{{ field.name }} (:class:`{{ field.ident.sphinx }}`):
311311
{{ field.meta.doc|rst(width=72, indent=16) }}
@@ -316,7 +316,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
316316
{% else %}
317317
requests (Iterator[`{{ method.input.ident.sphinx }}`]):
318318
The request object iterator.{{ ' ' }}
319-
{{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
319+
{{- method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
320320
{% endif %}
321321
retry (google.api_core.retry.Retry): Designation of what errors, if any,
322322
should be retried.
@@ -344,7 +344,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
344344
'the individual field arguments should be set.')
345345

346346
{% endif %} {# method.flattened_fields #}
347-
{% if method.input.ident.package != method.ident.package %} {# request lives in a different package, so there is no proto wrapper #}
347+
{% if method.input.ident.package != method.ident.package %}{# request lives in a different package, so there is no proto wrapper #}
348348
# The request isn't a proto-plus wrapped type.
349349
# so it must be constructed via keyword expansion.
350350
if isinstance(request, dict):

gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/transports/grpc.py.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ class {{ service.name }}GrpcTransport({{ service.name }}Transport):
217217
def {{ method.name|snake_case }}(self) -> Callable[
218218
[{{ method.input.ident }}],
219219
{{ method.output.ident }}]:
220-
r"""Return a callable for the {{ ' ' }}
221-
{{ (method.name|snake_case).replace('_',' ')|wrap(
222-
width=70, offset=40, indent=8) }}
223-
{{ ' ' }} method over gRPC.
220+
r"""Return a callable for the{{ ' ' }}
221+
{{- (method.name|snake_case).replace('_',' ')|wrap(
222+
width=70, offset=40, indent=8) -}}
223+
{{ ' ' }}method over gRPC.
224224

225225
{{ method.meta.doc|rst(width=72, indent=8) }}
226226

gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class {{ service.async_client_name }}:
166166
{% if not method.client_streaming %}
167167
request (:class:`{{ method.input.ident.sphinx }}`):
168168
The request object.{{ ' ' }}
169-
{{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
169+
{{- method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
170170
{% for key, field in method.flattened_fields.items() %}
171171
{{ field.name }} (:class:`{{ field.ident.sphinx }}`):
172172
{{ field.meta.doc|rst(width=72, indent=16) }}
@@ -177,7 +177,7 @@ class {{ service.async_client_name }}:
177177
{% else %}
178178
requests (AsyncIterator[`{{ method.input.ident.sphinx }}`]):
179179
The request object AsyncIterator.{{ ' ' }}
180-
{{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
180+
{{- method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
181181
{% endif %}
182182
retry (google.api_core.retry.Retry): Designation of what errors, if any,
183183
should be retried.

gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
320320
{% if not method.client_streaming %}
321321
request ({{ method.input.ident.sphinx }}):
322322
The request object.{{ ' ' }}
323-
{{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
323+
{{- method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
324324
{% for key, field in method.flattened_fields.items() %}
325325
{{ field.name }} ({{ field.ident.sphinx }}):
326326
{{ field.meta.doc|rst(width=72, indent=16) }}
@@ -331,7 +331,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
331331
{% else %}
332332
requests (Iterator[{{ method.input.ident.sphinx }}]):
333333
The request object iterator.{{ ' ' }}
334-
{{ method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
334+
{{- method.input.meta.doc|wrap(width=72, offset=36, indent=16) }}
335335
{% endif %}
336336
retry (google.api_core.retry.Retry): Designation of what errors, if any,
337337
should be retried.
@@ -360,7 +360,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
360360
'the individual field arguments should be set.')
361361

362362
{% endif %}
363-
{% if method.input.ident.package != method.ident.package %} {# request lives in a different package, so there is no proto wrapper #}
363+
{% if method.input.ident.package != method.ident.package %}{# request lives in a different package, so there is no proto wrapper #}
364364
if isinstance(request, dict):
365365
# The request isn't a proto-plus wrapped type,
366366
# so it must be constructed via keyword expansion.
@@ -375,7 +375,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
375375
# there are no flattened fields.
376376
if not isinstance(request, {{ method.input.ident }}):
377377
request = {{ method.input.ident }}(request)
378-
{% endif %} {# different request package #}
378+
{% endif %}{# different request package #}
379379

380380
{#- Vanilla python protobuf wrapper types cannot _set_ repeated fields #}
381381
{% if method.flattened_fields and method.input.ident.package == method.ident.package %}

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/grpc.py.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ class {{ service.name }}GrpcTransport({{ service.name }}Transport):
244244
def {{ method.name|snake_case }}(self) -> Callable[
245245
[{{ method.input.ident }}],
246246
{{ method.output.ident }}]:
247-
r"""Return a callable for the {{ ' ' }}
248-
{{ (method.name|snake_case).replace('_',' ')|wrap(
249-
width=70, offset=40, indent=8) }}
250-
{{ ' ' }} method over gRPC.
247+
r"""Return a callable for the{{ ' ' }}
248+
{{- (method.name|snake_case).replace('_',' ')|wrap(
249+
width=70, offset=40, indent=8) -}}
250+
{{ ' ' }}method over gRPC.
251251

252252
{{ method.meta.doc|rst(width=72, indent=8) }}
253253

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/grpc_asyncio.py.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
248248
def {{ method.name|snake_case }}(self) -> Callable[
249249
[{{ method.input.ident }}],
250250
Awaitable[{{ method.output.ident }}]]:
251-
r"""Return a callable for the {{ ' ' }}
252-
{{ (method.name|snake_case).replace('_',' ')|wrap(
253-
width=70, offset=40, indent=8) }}
254-
{{ ' ' }} method over gRPC.
251+
r"""Return a callable for the{{ ' ' }}
252+
{{- (method.name|snake_case).replace('_',' ')|wrap(
253+
width=70, offset=40, indent=8) -}}
254+
{{ ' ' }}method over gRPC.
255255

256256
{{ method.meta.doc|rst(width=72, indent=8) }}
257257

gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class {{ service.name }}RestTransport({{ service.name }}Transport):
141141

142142
Args:
143143
request (~.{{ method.input.ident }}):
144-
The request object.
145-
{{ method.input.meta.doc|rst(width=72, indent=16) }}
144+
The request object.{{ ' ' }}
145+
{{- method.input.meta.doc|rst(width=72, indent=16) }}
146146
metadata (Sequence[Tuple[str, str]]): Strings which should be
147147
sent along with the request as metadata.
148148
{% if not method.void %}

gapic/templates/%namespace/%name_%version/%sub/types/_message.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class {{ message.name }}({{ p }}.Message):
3737
{{ field.name }} = {{ p }}.MapField(
3838
{{ p }}.{{ key_field.proto_type }},
3939
{{ p }}.{{ value_field.proto_type }},
40-
number={{ field.number }}
40+
number={{ field.number }},
4141
{% if value_field.enum or value_field.message %}
4242
{{ value_field.proto_type.lower() }}={{ value_field.type.ident.rel(message.ident) }},
4343
{% endif %}{# enum or message#}

gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,10 +1485,9 @@ def test_{{ service.name|snake_case }}_base_transport_with_credentials_file():
14851485
load_creds.assert_called_once_with("credentials.json",
14861486
scopes=None,
14871487
default_scopes=(
1488-
{%- for scope in service.oauth_scopes %}
1488+
{% for scope in service.oauth_scopes %}
14891489
'{{ scope }}',
1490-
{%- endfor %}
1491-
),
1490+
{% endfor %}),
14921491
quota_project_id="octopus",
14931492
)
14941493

@@ -1533,7 +1532,6 @@ def test_{{ service.name|snake_case }}_auth_adc():
15331532
{% for scope in service.oauth_scopes %}
15341533
'{{ scope }}',
15351534
{% endfor %}),
1536-
15371535
quota_project_id=None,
15381536
)
15391537

@@ -1623,14 +1621,14 @@ def test_{{ service.name|snake_case }}_transport_create_channel(transport_class,
16231621

16241622
{% with host = (service.host|default('localhost', true)) %}
16251623
create_channel.assert_called_with(
1626-
"{{ host }}",
1624+
"{{ host }}{% if ":" not in service.host %}:443{% endif %}",
16271625
credentials=creds,
16281626
credentials_file=None,
16291627
quota_project_id="octopus",
16301628
default_scopes=(
1631-
{%- for scope in service.oauth_scopes %}
1629+
{% for scope in service.oauth_scopes %}
16321630
'{{ scope }}',
1633-
{%- endfor %}),
1631+
{% endfor %}),
16341632
scopes=["1", "2"],
16351633
default_host="{{ host }}",
16361634
ssl_credentials=None,
@@ -1667,9 +1665,9 @@ def test_{{ service.name|snake_case }}_transport_create_channel_old_api_core(tra
16671665
credentials_file=None,
16681666
quota_project_id="octopus",
16691667
scopes=(
1670-
{%- for scope in service.oauth_scopes %}
1668+
{% for scope in service.oauth_scopes %}
16711669
'{{ scope }}',
1672-
{%- endfor %}),
1670+
{% endfor %}),
16731671
ssl_credentials=None,
16741672
options=[
16751673
("grpc.max_send_message_length", -1),

0 commit comments

Comments
 (0)