@@ -5,18 +5,18 @@ from collections import OrderedDict
55from distutils import util
66import os
77import re
8- from typing import Callable, Dict, {% if service .any_server_streaming %} Iterable, {% endif %}{% if service .any_client_streaming %} Iterator, {% endif %} Sequence, Tuple, Type, Union
8+ from typing import Callable, Dict, Optional, {% if service .any_server_streaming %} Iterable, {% endif %}{% if service .any_client_streaming %} Iterator, {% endif %} Sequence, Tuple, Type, Union
99import pkg_resources
1010
11- import google.api_core. client_options as ClientOptions # type: ignore
12- from google.api_core import exceptions # type: ignore
13- from google.api_core import gapic_v1 # type: ignore
14- from google.api_core import retry as retries # type: ignore
15- from google.auth import credentials # type: ignore
16- from google.auth.transport import mtls # type: ignore
17- from google.auth.transport.grpc import SslCredentials # type: ignore
18- from google.auth.exceptions import MutualTLSChannelError # type: ignore
19- from google.oauth2 import service_account # type: ignore
11+ from google.api_core import client_options as client_options_lib # type: ignore
12+ from google.api_core import exceptions # type: ignore
13+ from google.api_core import gapic_v1 # type: ignore
14+ from google.api_core import retry as retries # type: ignore
15+ from google.auth import credentials # type: ignore
16+ from google.auth.transport import mtls # type: ignore
17+ from google.auth.transport.grpc import SslCredentials # type: ignore
18+ from google.auth.exceptions import MutualTLSChannelError # type: ignore
19+ from google.oauth2 import service_account # type: ignore
2020
2121{% filter sort_lines -%}
2222{% for method in service .methods .values () -%}
@@ -134,9 +134,9 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
134134 {% endfor %}
135135
136136 def __init__(self, *,
137- credentials: credentials.Credentials = None,
138- transport: Union[str, {{ service.name }}Transport] = None,
139- client_options: ClientOptions = None,
137+ credentials: Optional[ credentials.Credentials] = None,
138+ transport: Union[str, {{ service.name }}Transport, None ] = None,
139+ client_options: Optional[client_options_lib. ClientOptions] = None,
140140 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
141141 ) -> None:
142142 """Instantiate the {{ (service.client_name|snake_case).replace('_', ' ') }}.
@@ -150,8 +150,8 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
150150 transport (Union[str, ~.{{ service.name }}Transport]): The
151151 transport to use. If set to None, a transport is chosen
152152 automatically.
153- client_options (ClientOptions): Custom options for the client. It
154- won't take effect unless ``transport`` is None .
153+ client_options (client_options_lib. ClientOptions): Custom options for the
154+ client. It won't take effect if a ``transport`` instance is provided .
155155 (1) The ``api_endpoint`` property can be used to override the
156156 default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
157157 environment variable can also be used to override the endpoint:
@@ -171,19 +171,19 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta):
171171 API requests. If ``None``, then default info will be used.
172172 Generally, you only need to set this if you're developing
173173 your own client library.
174-
174+
175175 Raises:
176176 google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
177177 creation failed for any reason.
178178 """
179179 if isinstance(client_options, dict):
180- client_options = ClientOptions .from_dict(client_options)
180+ client_options = client_options_lib .from_dict(client_options)
181181 if client_options is None:
182- client_options = ClientOptions .ClientOptions()
182+ client_options = client_options_lib .ClientOptions()
183183
184184 # Create SSL credentials for mutual TLS if needed.
185185 use_client_cert = bool(util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")))
186-
186+
187187 ssl_credentials = None
188188 is_mtls = False
189189 if use_client_cert:
0 commit comments