Skip to content

Commit 2074029

Browse files
authored
chore(bigquery): centralize mypy config for bigquery (#17640)
* Relies on a centralized `mypy.ini` file at the root of the repository to consolidate all shared and package-specific mypy exceptions. * Deletes the individual `mypy.ini` files from handwritten libraries, establishing the root configuration as the source of truth. * Refactored their `noxfile.py` files to define `MYPY_CONFIG_FILE` dynamically and standardized their `session.run("mypy", ...)` invocations. Related to: PR #17409 and PR #17641 > [!note] > all three PRs rely on the same centralized mypy.ini config. So you may see some minor edits in the main config that are applicable to packages in one of the other PRs. This will have no effect on those packages until their noxfiles are updated to begin using the new centralized config.
1 parent 87ef1f5 commit 2074029

3 files changed

Lines changed: 54 additions & 12 deletions

File tree

mypy.ini

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ exclude = (?x)(
1414
| (^|/)tests/unit/gapic/
1515
)
1616

17-
1817
# ==============================================================================
1918
# GLOBAL THIRD-PARTY & SHARED LIBRARY IGNORES
2019
# ==============================================================================
@@ -28,13 +27,7 @@ ignore_missing_imports = True
2827
[mypy-flask]
2928
ignore_missing_imports = True
3029

31-
[mypy-google.auth.*]
32-
ignore_missing_imports = True
33-
34-
[mypy-google.cloud.bigtable]
35-
ignore_missing_imports = True
36-
37-
[mypy-google.cloud.pubsub]
30+
[mypy-google.api.*]
3831
ignore_missing_imports = True
3932

4033
[mypy-google.colab]
@@ -61,6 +54,9 @@ ignore_missing_imports = True
6154
[mypy-grpc.*]
6255
ignore_missing_imports = True
6356

57+
[mypy-grpc_status]
58+
ignore_missing_imports = True
59+
6460
[mypy-ibis.*]
6561
ignore_missing_imports = True
6662

@@ -86,8 +82,18 @@ ignore_missing_imports = True
8682
# ==============================================================================
8783
# PACKAGE-SPECIFIC OVERRIDES & EXCEPTIONS
8884
# ==============================================================================
85+
# --- bigframes ---
86+
[mypy-bigframes_vendored.*]
87+
ignore_errors = True
88+
89+
# --- google-auth ---
90+
[mypy-google.auth.*]
91+
ignore_missing_imports = True
8992

9093
# --- google-cloud-bigtable ---
94+
[mypy-google.cloud.bigtable]
95+
ignore_missing_imports = True
96+
9197
[mypy-google.cloud.bigtable.*]
9298
ignore_errors = True
9399

@@ -97,4 +103,26 @@ warn_unreachable = True
97103
disallow_any_generics = True
98104
ignore_errors = False
99105

106+
[mypy-google.cloud.bigtable_admin.*]
107+
ignore_errors = True
108+
109+
[mypy-google.cloud.bigtable_admin_v2.*]
110+
ignore_errors = True
111+
112+
[mypy-google.cloud.bigtable_v2.*]
113+
ignore_errors = True
100114

115+
# --- google-cloud-datastore ---
116+
[mypy-google.cloud.datastore.*]
117+
ignore_missing_imports = True
118+
119+
[mypy-google.cloud.datastore._app_engine_key_pb2]
120+
ignore_errors = True
121+
122+
# --- google-cloud-firestore ---
123+
[mypy-google.cloud.firestore.*]
124+
check_untyped_defs = True
125+
126+
# --- google-cloud-pubsub ---
127+
[mypy-google.cloud.pubsub]
128+
ignore_missing_imports = True

packages/google-cloud-bigquery/mypy.ini

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/google-cloud-bigquery/noxfile.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@
4141
ALL_PYTHON = ["3.10", "3.11", "3.12", "3.13", "3.14"]
4242
UNIT_TEST_PYTHON_VERSIONS = ALL_PYTHON
4343
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
44+
# Path to the centralized mypy configuration file at the repository root.
45+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
46+
MYPY_CONFIG_FILE = next(
47+
(
48+
str(p / "mypy.ini")
49+
for p in CURRENT_DIRECTORY.parents
50+
if (p / "mypy.ini").exists()
51+
),
52+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
53+
)
54+
4455

4556
SYSTEM_TEST_PYTHON_VERSIONS = UNIT_TEST_PYTHON_VERSIONS
4657

@@ -215,7 +226,13 @@ def mypy(session):
215226
)
216227
session.run("python", "-m", "pip", "freeze")
217228
with log_package_context(session):
218-
session.run("mypy", "-p", "google", "--show-traceback")
229+
session.run(
230+
"mypy",
231+
f"--config-file={MYPY_CONFIG_FILE}",
232+
"-p",
233+
"google",
234+
"--show-traceback",
235+
)
219236

220237

221238
@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)

0 commit comments

Comments
 (0)