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

Commit 868fe4d

Browse files
committed
add comments
1 parent 81a97d3 commit 868fe4d

File tree

16 files changed

+39
-5
lines changed

16 files changed

+39
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def _get_http_options():
227227
request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri'])
228228
method = transcoded_request['method']
229229
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2137): Remove `type: ignore` once version check is added for google-api-core. #}
230+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
230231
raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore # fmt: skip
231232
{% else %}
232233
raise core_exceptions.from_http_response(response)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
131131

132132
DEFAULT_ENDPOINT = {% if service.host %}"{{ service.host }}"{% else %}None{% endif %}
133133

134+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
134135
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore # fmt: skip
135136
DEFAULT_ENDPOINT
136137
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class {{service.name}}RestTransport(_Base{{ service.name }}RestTransport):
273273
{{method.output.ident}}]:
274274
# The return type is fine, but mypy isn't sophisticated enough to determine what's going on here.
275275
# In C++ this would require a dynamic_cast
276+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
276277
return self._{{method.name}}(self._session, self._host, self._interceptor) # type: ignore # fmt: skip
277278

278279
{% endfor %}

gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import sys
1010

1111
__version__ = package_version.__version__
1212

13+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
1314
if sys.version_info >= (3, 8): # pragma: NO COVER # fmt: skip
1415
from importlib import metadata
16+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
1517
else: # pragma: NO COVER # fmt: skip
1618
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
1719
# this code path once we drop support for Python 3.7
@@ -46,10 +48,12 @@ from .types.{{ proto.module_name }} import {{ enum.name }}
4648
{% endfor %}
4749
{% endfor %}
4850

51+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
4952
if hasattr(api_core, "check_python_version") and hasattr(api_core, "check_dependency_versions"): # pragma: NO COVER # fmt: skip
5053
{# TODO(api_core): remove `type:ignore` below when minimum version of api_core makes the else clause unnecessary. #}
5154
api_core.check_python_version("{{package_path}}") # type: ignore
5255
api_core.check_dependency_versions("{{package_path}}") # type: ignore
56+
{# Add `# pragma: NO COVER` to keep `# pragma: NO COVER` on the same line #}
5357
else: # pragma: NO COVER # fmt: skip
5458
{# TODO(api_core): Remove this try-catch when we require api-core at a version that
5559
supports the changes in https://github.com/googleapis/python-api-core/pull/832

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ except ImportError: # pragma: NO COVER
104104
`add_google_api_core_version_header_import` to add the necessary import statements.
105105
#}
106106
{% if service_version %}
107+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
107108
if HAS_GOOGLE_API_CORE_VERSION_HEADER: # pragma: NO COVER # fmt: skip
108109
metadata = tuple(metadata) + (
109110
version_header.to_api_version_header("{{ service_version }}"),
@@ -214,6 +215,7 @@ def _get_http_options():
214215
# Jsonify the query params
215216
query_params = _Base{{ service_name }}RestTransport._Base{{method_name}}._get_query_params_json(transcoded_request)
216217

218+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
217219
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER # fmt: skip
218220
request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri'])
219221
method = transcoded_request['method']
@@ -256,6 +258,7 @@ def _get_http_options():
256258
request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri'])
257259
method = transcoded_request['method']
258260
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2137): Remove `type: ignore` once version check is added for google-api-core. #}
261+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
259262
raise core_exceptions.format_http_response_error(response, method, request_url, payload) # type: ignore # fmt: skip
260263
{% else %}
261264
raise core_exceptions.from_http_response(response)
@@ -266,6 +269,7 @@ def _get_http_options():
266269

267270
{% macro unary_request_interceptor_common(service) %}
268271
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG)
272+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
269273
if logging_enabled: # pragma: NO COVER # fmt: skip
270274
request_metadata = client_call_details.metadata
271275
if isinstance(request, proto.Message):
@@ -354,6 +358,7 @@ See related issue: https://github.com/googleapis/gapic-generator-python/issues/2
354358
{% macro wrap_async_method_macro() %}
355359
def _wrap_method(self, func, *args, **kwargs):
356360
{# TODO: Remove `pragma: NO COVER` once https://github.com/googleapis/python-api-core/pull/688 is merged. #}
361+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
357362
if self._wrap_with_kind: # pragma: NO COVER # fmt: skip
358363
kwargs["kind"] = self.kind
359364
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
@@ -488,6 +493,7 @@ class {{ async_method_name_prefix }}{{ service.name }}RestInterceptor:
488493

489494
@property
490495
def {{ name|snake_case }}(self):
496+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
491497
return self.{{ name|make_private }}(self._session, self._host, self._interceptor) # type: ignore # fmt: skip
492498

493499
class {{ name|make_private }}(_Base{{ service.name }}RestTransport._Base{{name}}, {{ async_method_name_prefix }}{{service.name}}RestStub):
@@ -534,6 +540,7 @@ class {{ name|make_private }}(_Base{{ service.name }}RestTransport._Base{{name}}
534540
resp = {{ sig.response_type }}()
535541
resp = json_format.Parse(content, resp)
536542
resp = {{ await_prefix }}self._interceptor.post_{{ name|snake_case }}(resp)
543+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
537544
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER # fmt: skip
538545
try:
539546
response_payload = json_format.MessageToJson(resp)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class {{ service.async_client_name }}:
9898
Returns:
9999
{{ service.async_client_name }}: The constructed client.
100100
"""
101+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
101102
return {{ service.client_name }}.from_service_account_info.__func__({{ service.async_client_name }}, info, *args, **kwargs) # type: ignore # fmt: skip
102103

103104
@classmethod
@@ -114,6 +115,7 @@ class {{ service.async_client_name }}:
114115
Returns:
115116
{{ service.async_client_name }}: The constructed client.
116117
"""
118+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
117119
return {{ service.client_name }}.from_service_account_file.__func__({{ service.async_client_name }}, filename, *args, **kwargs) # type: ignore # fmt: skip
118120

119121
from_service_account_json = from_service_account_file
@@ -150,6 +152,7 @@ class {{ service.async_client_name }}:
150152
Raises:
151153
google.auth.exceptions.MutualTLSChannelError: If any errors happen.
152154
"""
155+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
153156
return {{ service.client_name }}.get_mtls_endpoint_and_cert_source(client_options) # type: ignore # fmt: skip
154157

155158
@property
@@ -252,6 +255,7 @@ class {{ service.async_client_name }}:
252255

253256
)
254257

258+
{# Add ` # fmt: skip` to keep `# pragma: NO COVER` on the same line #}
255259
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER # fmt: skip
256260
_LOGGER.debug(
257261
"Created client `{{ service.meta.address.proto_package_versioned }}.{{ service.async_client_name }}`.",

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class {{ service.client_name }}Meta(type):
127127
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove this condition when async rest is GA. #}
128128
{% if rest_async_io_enabled %}
129129
{# NOTE: `pragma: NO COVER` is needed since the coverage for presubmits isn't combined. #}
130+
{# Add ` # fmt: skip` to keep `# pragma: NO COVER` on the same line #}
130131
if label == "rest_asyncio" and not HAS_ASYNC_REST_DEPENDENCIES: # pragma: NO COVER # fmt: skip
131132
raise ASYNC_REST_EXCEPTION
132133
{% endif %}
@@ -175,6 +176,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
175176
# Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
176177
DEFAULT_ENDPOINT = {% if service.host %}"{{ service.host }}"{% else %}None{% endif %}
177178

179+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
178180
DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore # fmt: skip
179181
DEFAULT_ENDPOINT
180182
)
@@ -568,6 +570,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
568570
# Initialize the universe domain validation.
569571
self._is_universe_domain_valid = False
570572

573+
{# Add ` # fmt: skip` to keep `# pragma: NO COVER` on the same line #}
571574
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER # fmt: skip
572575
# Setup logging.
573576
client_logging.initialize_logging()
@@ -660,6 +663,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
660663
)
661664

662665
if "async" not in str(self._transport):
666+
{# Add ` # pragma: NO COVER` to keep `# type: ignore` on the same line #}
663667
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER # fmt: skip
664668
_LOGGER.debug(
665669
"Created client `{{ service.meta.address.proto_package_versioned }}.{{ service.client_name }}`.",
@@ -1014,6 +1018,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
10141018

10151019
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__)
10161020

1021+
{# Add ` # fmt: skip` to keep `# pragma: NO COVER` on the same line #}
10171022
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER # fmt: skip
10181023
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
10191024

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ _transport_registry['grpc_asyncio'] = {{ service.name }}GrpcAsyncIOTransport
3939
{% if 'rest' in opts.transport %}
4040
_transport_registry['rest'] = {{ service.name }}RestTransport
4141
{% if rest_async_io_enabled %}
42+
{# Add ` # fmt: skip` to keep `# pragma: NO COVER` on the same line #}
4243
if HAS_REST_ASYNC: # pragma: NO COVER # fmt: skip
4344
_transport_registry['rest_asyncio'] = Async{{ service.name }}RestTransport
4445
{% endif %}{# if rest_async_io_enabled #}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ from {{ (api.naming.module_namespace + (api.naming.versioned_module_name,) + ser
5252

5353
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__)
5454

55+
{# Add `# fmt: skip` to keep `# type: ignore` on the same line #}
5556
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER # fmt: skip
5657
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
5758

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO
6363
def intercept_unary_unary(self, continuation, client_call_details, request):
6464
{{ shared_macros.unary_request_interceptor_common(service) }}
6565
response = continuation(client_call_details, request)
66+
{# Add `# fmt: skip` to keep `# pragma: NO COVER` on the same line #}
6667
if logging_enabled: # pragma: NO COVER # fmt: skip
6768
response_metadata = response.trailing_metadata()
6869
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples

0 commit comments

Comments
 (0)