|
15 | 15 | """This script is used to synthesize generated parts of this library.""" |
16 | 16 |
|
17 | 17 | from pathlib import Path |
| 18 | +import re |
18 | 19 | from typing import List, Optional |
19 | 20 |
|
20 | 21 | import synthtool as s |
@@ -165,16 +166,53 @@ def lint_setup_py\(session\): |
165 | 166 | def mypy(session): |
166 | 167 | """Verify type hints are mypy compatible.""" |
167 | 168 | session.install("-e", ".") |
168 | | - session.install("mypy", "types-setuptools") |
| 169 | + session.install("mypy", "types-setuptools", "types-protobuf", "types-mock") |
| 170 | + session.install("google-cloud-testutils") |
169 | 171 | # TODO: also verify types on tests, all of google package |
170 | | - session.run("mypy", "-p", "google.cloud.bigtable", "--no-incremental") |
| 172 | + session.run("mypy", "google/", "tests/") |
171 | 173 |
|
172 | 174 |
|
173 | 175 | @nox.session(python=DEFAULT_PYTHON_VERSION) |
174 | 176 | def lint_setup_py(session): |
175 | 177 | ''', |
176 | 178 | ) |
177 | 179 |
|
| 180 | +# Work around https://github.com/googleapis/gapic-generator-python/issues/689 |
| 181 | +bad_clusters_typing = r""" |
| 182 | + clusters: Sequence\[ |
| 183 | + bigtable_instance_admin\.CreateInstanceRequest\.ClustersEntry |
| 184 | + \] = None,""" |
| 185 | + |
| 186 | +good_clusters_typing = """ |
| 187 | + clusters: Dict[str, gba_instance.Cluster] = None,""" |
| 188 | + |
| 189 | +s.replace( |
| 190 | + "google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/*client.py", |
| 191 | + bad_clusters_typing, |
| 192 | + good_clusters_typing, |
| 193 | +) |
| 194 | + |
| 195 | +bad_clusters_docstring_1 = re.escape(r""" |
| 196 | + clusters (:class:`Sequence[google.cloud.bigtable_admin_v2.types.CreateInstanceRequest.ClustersEntry]`):""") |
| 197 | + |
| 198 | +bad_clusters_docstring_2 = re.escape(r""" |
| 199 | + clusters (Sequence[google.cloud.bigtable_admin_v2.types.CreateInstanceRequest.ClustersEntry]):""") |
| 200 | + |
| 201 | +good_clusters_docstring = """ |
| 202 | + clusters (Dict[str, gba_instance.Cluster]):""" |
| 203 | + |
| 204 | +s.replace( |
| 205 | + "google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/*client.py", |
| 206 | + bad_clusters_docstring_1, |
| 207 | + good_clusters_docstring, |
| 208 | +) |
| 209 | + |
| 210 | +s.replace( |
| 211 | + "google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/*client.py", |
| 212 | + bad_clusters_docstring_2, |
| 213 | + good_clusters_docstring, |
| 214 | +) |
| 215 | + |
178 | 216 | # ---------------------------------------------------------------------------- |
179 | 217 | # Samples templates |
180 | 218 | # ---------------------------------------------------------------------------- |
|
0 commit comments