Skip to content

Commit 6253415

Browse files
authored
chore: fix 'pytype' via manual synth (#201)
Supersedes: #197, #198, #199
1 parent 637f915 commit 6253415

9 files changed

Lines changed: 62 additions & 96 deletions

File tree

packages/google-cloud-firestore/.kokoro/build.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,5 @@ python3.6 -m nox --version
4444
if [[ -n "${NOX_SESSION:-}" ]]; then
4545
python3.6 -m nox -s "${NOX_SESSION:-}"
4646
else
47-
# TODO: Currently generated type metadata, ignores, cause many errors.
48-
# For now, disable pytype in CI runs
49-
python3.6 -m nox -k "not pytype"
47+
python3.6 -m nox
5048
fi

packages/google-cloud-firestore/CONTRIBUTING.rst

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,6 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
8080

8181
.. nox: https://pypi.org/project/nox/
8282
83-
Note on Editable Installs / Develop Mode
84-
========================================
85-
86-
- As mentioned previously, using ``setuptools`` in `develop mode`_
87-
or a ``pip`` `editable install`_ is not possible with this
88-
library. This is because this library uses `namespace packages`_.
89-
For context see `Issue #2316`_ and the relevant `PyPA issue`_.
90-
91-
Since ``editable`` / ``develop`` mode can't be used, packages
92-
need to be installed directly. Hence your changes to the source
93-
tree don't get incorporated into the **already installed**
94-
package.
95-
96-
.. _namespace packages: https://www.python.org/dev/peps/pep-0420/
97-
.. _Issue #2316: https://github.com/GoogleCloudPlatform/google-cloud-python/issues/2316
98-
.. _PyPA issue: https://github.com/pypa/packaging-problems/issues/12
99-
.. _develop mode: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
100-
.. _editable install: https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs
101-
10283
*****************************************
10384
I'm getting weird errors... Can you help?
10485
*****************************************

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/services/firestore_admin/async_client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
from google.auth import credentials # type: ignore
2929
from google.oauth2 import service_account # type: ignore
3030

31-
from google.api_core import operation as ga_operation
32-
from google.api_core import operation_async
31+
from google.api_core import operation as ga_operation # type: ignore
32+
from google.api_core import operation_async # type: ignore
3333
from google.cloud.firestore_admin_v1.services.firestore_admin import pagers
3434
from google.cloud.firestore_admin_v1.types import field
3535
from google.cloud.firestore_admin_v1.types import field as gfa_field
@@ -273,9 +273,9 @@ async def list_indexes(
273273
maximum=60.0,
274274
multiplier=1.3,
275275
predicate=retries.if_exception_type(
276-
exceptions.InternalServerError,
277-
exceptions.ServiceUnavailable,
278276
exceptions.DeadlineExceeded,
277+
exceptions.ServiceUnavailable,
278+
exceptions.InternalServerError,
279279
),
280280
),
281281
default_timeout=60.0,
@@ -361,9 +361,9 @@ async def get_index(
361361
maximum=60.0,
362362
multiplier=1.3,
363363
predicate=retries.if_exception_type(
364-
exceptions.InternalServerError,
365-
exceptions.ServiceUnavailable,
366364
exceptions.DeadlineExceeded,
365+
exceptions.ServiceUnavailable,
366+
exceptions.InternalServerError,
367367
),
368368
),
369369
default_timeout=60.0,
@@ -436,9 +436,9 @@ async def delete_index(
436436
maximum=60.0,
437437
multiplier=1.3,
438438
predicate=retries.if_exception_type(
439-
exceptions.InternalServerError,
440-
exceptions.ServiceUnavailable,
441439
exceptions.DeadlineExceeded,
440+
exceptions.ServiceUnavailable,
441+
exceptions.InternalServerError,
442442
),
443443
),
444444
default_timeout=60.0,
@@ -519,9 +519,9 @@ async def get_field(
519519
maximum=60.0,
520520
multiplier=1.3,
521521
predicate=retries.if_exception_type(
522-
exceptions.InternalServerError,
523-
exceptions.ServiceUnavailable,
524522
exceptions.DeadlineExceeded,
523+
exceptions.ServiceUnavailable,
524+
exceptions.InternalServerError,
525525
),
526526
),
527527
default_timeout=60.0,
@@ -712,9 +712,9 @@ async def list_fields(
712712
maximum=60.0,
713713
multiplier=1.3,
714714
predicate=retries.if_exception_type(
715-
exceptions.InternalServerError,
716-
exceptions.ServiceUnavailable,
717715
exceptions.DeadlineExceeded,
716+
exceptions.ServiceUnavailable,
717+
exceptions.InternalServerError,
718718
),
719719
),
720720
default_timeout=60.0,

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/services/firestore_admin/client.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
from distutils import util
2020
import os
2121
import re
22-
from typing import Callable, Dict, Sequence, Tuple, Type, Union
22+
from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
2323
import pkg_resources
2424

25-
import google.api_core.client_options as ClientOptions # type: ignore
25+
from google.api_core import client_options as client_options_lib # type: ignore
2626
from google.api_core import exceptions # type: ignore
2727
from google.api_core import gapic_v1 # type: ignore
2828
from google.api_core import retry as retries # type: ignore
@@ -32,9 +32,8 @@
3232
from google.auth.exceptions import MutualTLSChannelError # type: ignore
3333
from google.oauth2 import service_account # type: ignore
3434

35-
from google.api_core import operation as ga_operation
36-
from google.api_core import operation
37-
from google.api_core import operation_async
35+
from google.api_core import operation as ga_operation # type: ignore
36+
from google.api_core import operation_async # type: ignore
3837
from google.cloud.firestore_admin_v1.services.firestore_admin import pagers
3938
from google.cloud.firestore_admin_v1.types import field
4039
from google.cloud.firestore_admin_v1.types import field as gfa_field
@@ -176,9 +175,9 @@ def parse_index_path(path: str) -> Dict[str, str]:
176175
def __init__(
177176
self,
178177
*,
179-
credentials: credentials.Credentials = None,
180-
transport: Union[str, FirestoreAdminTransport] = None,
181-
client_options: ClientOptions = None,
178+
credentials: Optional[credentials.Credentials] = None,
179+
transport: Union[str, FirestoreAdminTransport, None] = None,
180+
client_options: Optional[client_options_lib.ClientOptions] = None,
182181
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
183182
) -> None:
184183
"""Instantiate the firestore admin client.
@@ -192,8 +191,8 @@ def __init__(
192191
transport (Union[str, ~.FirestoreAdminTransport]): The
193192
transport to use. If set to None, a transport is chosen
194193
automatically.
195-
client_options (ClientOptions): Custom options for the client. It
196-
won't take effect if a ``transport`` instance is provided.
194+
client_options (client_options_lib.ClientOptions): Custom options for the
195+
client. It won't take effect if a ``transport`` instance is provided.
197196
(1) The ``api_endpoint`` property can be used to override the
198197
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
199198
environment variable can also be used to override the endpoint:
@@ -219,9 +218,9 @@ def __init__(
219218
creation failed for any reason.
220219
"""
221220
if isinstance(client_options, dict):
222-
client_options = ClientOptions.from_dict(client_options)
221+
client_options = client_options_lib.from_dict(client_options)
223222
if client_options is None:
224-
client_options = ClientOptions.ClientOptions()
223+
client_options = client_options_lib.ClientOptions()
225224

226225
# Create SSL credentials for mutual TLS if needed.
227226
use_client_cert = bool(
@@ -378,7 +377,7 @@ def create_index(
378377
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
379378

380379
# Wrap the response in an operation future.
381-
response = operation.from_gapic(
380+
response = ga_operation.from_gapic(
382381
response,
383382
self._transport.operations_client,
384383
gfa_index.Index,
@@ -780,7 +779,7 @@ def update_field(
780779
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
781780

782781
# Wrap the response in an operation future.
783-
response = operation.from_gapic(
782+
response = ga_operation.from_gapic(
784783
response,
785784
self._transport.operations_client,
786785
gfa_field.Field,
@@ -964,7 +963,7 @@ def export_documents(
964963
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
965964

966965
# Wrap the response in an operation future.
967-
response = operation.from_gapic(
966+
response = ga_operation.from_gapic(
968967
response,
969968
self._transport.operations_client,
970969
gfa_operation.ExportDocumentsResponse,
@@ -1066,7 +1065,7 @@ def import_documents(
10661065
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
10671066

10681067
# Wrap the response in an operation future.
1069-
response = operation.from_gapic(
1068+
response = ga_operation.from_gapic(
10701069
response,
10711070
self._transport.operations_client,
10721071
empty.Empty,

packages/google-cloud-firestore/google/cloud/firestore_admin_v1/services/firestore_admin/transports/base.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ def _prep_wrapped_messages(self, client_info):
124124
maximum=60.0,
125125
multiplier=1.3,
126126
predicate=retries.if_exception_type(
127-
exceptions.InternalServerError,
128-
exceptions.ServiceUnavailable,
129127
exceptions.DeadlineExceeded,
128+
exceptions.ServiceUnavailable,
129+
exceptions.InternalServerError,
130130
),
131131
),
132132
default_timeout=60.0,
@@ -139,9 +139,9 @@ def _prep_wrapped_messages(self, client_info):
139139
maximum=60.0,
140140
multiplier=1.3,
141141
predicate=retries.if_exception_type(
142-
exceptions.InternalServerError,
143-
exceptions.ServiceUnavailable,
144142
exceptions.DeadlineExceeded,
143+
exceptions.ServiceUnavailable,
144+
exceptions.InternalServerError,
145145
),
146146
),
147147
default_timeout=60.0,
@@ -154,9 +154,9 @@ def _prep_wrapped_messages(self, client_info):
154154
maximum=60.0,
155155
multiplier=1.3,
156156
predicate=retries.if_exception_type(
157-
exceptions.InternalServerError,
158-
exceptions.ServiceUnavailable,
159157
exceptions.DeadlineExceeded,
158+
exceptions.ServiceUnavailable,
159+
exceptions.InternalServerError,
160160
),
161161
),
162162
default_timeout=60.0,
@@ -169,9 +169,9 @@ def _prep_wrapped_messages(self, client_info):
169169
maximum=60.0,
170170
multiplier=1.3,
171171
predicate=retries.if_exception_type(
172-
exceptions.InternalServerError,
173-
exceptions.ServiceUnavailable,
174172
exceptions.DeadlineExceeded,
173+
exceptions.ServiceUnavailable,
174+
exceptions.InternalServerError,
175175
),
176176
),
177177
default_timeout=60.0,
@@ -187,9 +187,9 @@ def _prep_wrapped_messages(self, client_info):
187187
maximum=60.0,
188188
multiplier=1.3,
189189
predicate=retries.if_exception_type(
190-
exceptions.InternalServerError,
191-
exceptions.ServiceUnavailable,
192190
exceptions.DeadlineExceeded,
191+
exceptions.ServiceUnavailable,
192+
exceptions.InternalServerError,
193193
),
194194
),
195195
default_timeout=60.0,

packages/google-cloud-firestore/google/cloud/firestore_v1/services/firestore/client.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@
1919
from distutils import util
2020
import os
2121
import re
22-
from typing import Callable, Dict, Iterable, Iterator, Sequence, Tuple, Type, Union
22+
from typing import (
23+
Callable,
24+
Dict,
25+
Optional,
26+
Iterable,
27+
Iterator,
28+
Sequence,
29+
Tuple,
30+
Type,
31+
Union,
32+
)
2333
import pkg_resources
2434

25-
import google.api_core.client_options as ClientOptions # type: ignore
35+
from google.api_core import client_options as client_options_lib # type: ignore
2636
from google.api_core import exceptions # type: ignore
2737
from google.api_core import gapic_v1 # type: ignore
2838
from google.api_core import retry as retries # type: ignore
@@ -146,9 +156,9 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
146156
def __init__(
147157
self,
148158
*,
149-
credentials: credentials.Credentials = None,
150-
transport: Union[str, FirestoreTransport] = None,
151-
client_options: ClientOptions = None,
159+
credentials: Optional[credentials.Credentials] = None,
160+
transport: Union[str, FirestoreTransport, None] = None,
161+
client_options: Optional[client_options_lib.ClientOptions] = None,
152162
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
153163
) -> None:
154164
"""Instantiate the firestore client.
@@ -162,8 +172,8 @@ def __init__(
162172
transport (Union[str, ~.FirestoreTransport]): The
163173
transport to use. If set to None, a transport is chosen
164174
automatically.
165-
client_options (ClientOptions): Custom options for the client. It
166-
won't take effect if a ``transport`` instance is provided.
175+
client_options (client_options_lib.ClientOptions): Custom options for the
176+
client. It won't take effect if a ``transport`` instance is provided.
167177
(1) The ``api_endpoint`` property can be used to override the
168178
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
169179
environment variable can also be used to override the endpoint:
@@ -189,9 +199,9 @@ def __init__(
189199
creation failed for any reason.
190200
"""
191201
if isinstance(client_options, dict):
192-
client_options = ClientOptions.from_dict(client_options)
202+
client_options = client_options_lib.from_dict(client_options)
193203
if client_options is None:
194-
client_options = ClientOptions.ClientOptions()
204+
client_options = client_options_lib.ClientOptions()
195205

196206
# Create SSL credentials for mutual TLS if needed.
197207
use_client_cert = bool(

packages/google-cloud-firestore/synth.metadata

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
"git": {
55
"name": ".",
66
"remote": "git@github.com:googleapis/python-firestore",
7-
"sha": "bae2f9299d7a2e97e5487898974f90c3f4fd6960"
7+
"sha": "ce6341df6ffc075f5db71b42facbcb60ad43d391"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "googleapis",
1313
"remote": "https://github.com/googleapis/googleapis.git",
14-
"sha": "8d73f9486fc193a150f6c907dfb9f49431aff3ff",
15-
"internalRef": "332497859"
14+
"sha": "7e377ce8f06ced48a79b45d97eebccb8a51f1e28",
15+
"internalRef": "333323660"
1616
}
1717
},
1818
{
1919
"git": {
2020
"name": "synthtool",
2121
"remote": "https://github.com/googleapis/synthtool.git",
22-
"sha": "27f4406999b1eee29e04b09b2423a8e4646c7e24"
22+
"sha": "916c10e8581804df2b48a0f0457d848f3faa582e"
2323
}
2424
}
2525
],

packages/google-cloud-firestore/synth.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@
6565
s.move(library / f"tests", f"tests")
6666
s.move(library / "scripts")
6767

68-
s.replace(
69-
f"google/cloud/firestore_admin_v1/services/firestore_admin/client.py",
70-
f"from google.api_core import operation as ga_operation",
71-
f"from google.api_core import operation as ga_operation\nfrom google.api_core import operation",
72-
)
73-
7468

7569
# ----------------------------------------------------------------------------
7670
# Add templated files
@@ -180,22 +174,6 @@ def lint_setup_py(session):
180174
""""mock", "pytest", "pytest-asyncio", "google-cloud-testutils",""",
181175
)
182176

183-
# Turn of `pytype` on CI for now.
184-
185-
s.replace(
186-
".kokoro/build.sh",
187-
"""\
188-
else
189-
python3.6 -m nox
190-
""",
191-
"""\
192-
else
193-
# TODO: Currently generated type metadata, ignores, cause many errors.
194-
# For now, disable pytype in CI runs
195-
python3.6 -m nox -k "not pytype"
196-
""",
197-
)
198-
199177
s.shell.run(["nox", "-s", "blacken"], hide_output=False)
200178

201179
s.replace(

packages/google-cloud-firestore/tests/unit/gapic/firestore_admin_v1/test_firestore_admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from google.api_core import gapic_v1
3232
from google.api_core import grpc_helpers
3333
from google.api_core import grpc_helpers_async
34-
from google.api_core import operation_async
34+
from google.api_core import operation_async # type: ignore
3535
from google.api_core import operations_v1
3636
from google.auth import credentials
3737
from google.auth.exceptions import MutualTLSChannelError

0 commit comments

Comments
 (0)