Skip to content

Commit bcc10d0

Browse files
committed
feat(handwritten): centralize mypy config for hybrid packages and add overrides
1 parent 5e51fd4 commit bcc10d0

21 files changed

Lines changed: 610 additions & 154 deletions

File tree

mypy.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,20 @@ ignore_errors = False
100100
# --- bigframes ---
101101
[mypy-bigframes_vendored.*]
102102
ignore_errors = True
103+
104+
# --- google-cloud-datastore ---
105+
[mypy-google.cloud.datastore.*]
106+
ignore_missing_imports = True
107+
108+
[mypy-google.cloud.datastore._app_engine_key_pb2]
109+
ignore_errors = True
110+
111+
[mypy-google.cloud.datastore_v1.services.datastore.async_client]
112+
ignore_errors = True
113+
114+
[mypy-google.cloud.datastore_v1.services.datastore.client]
115+
ignore_errors = True
116+
117+
# --- google-cloud-firestore ---
118+
[mypy-google.cloud.firestore.*]
119+
check_untyped_defs = True

packages/google-cloud-bigtable/mypy.ini

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

packages/google-cloud-bigtable/noxfile.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@
6666
SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
6767

6868
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
69+
# Path to the centralized mypy configuration file at the repository root.
70+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
71+
MYPY_CONFIG_FILE = next(
72+
(
73+
str(p / "mypy.ini")
74+
for p in CURRENT_DIRECTORY.parents
75+
if (p / "mypy.ini").exists()
76+
),
77+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
78+
)
79+
6980

7081
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
7182
nox.options.sessions = [
@@ -175,7 +186,7 @@ def mypy(session):
175186
"types-requests",
176187
)
177188
session.install("google-cloud-testutils")
178-
session.run("mypy", "-p", "google.cloud.bigtable.data")
189+
session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "-p", "google.cloud.bigtable.data")
179190

180191

181192
@nox.session(python=DEFAULT_PYTHON_VERSION)

packages/google-cloud-datastore/mypy.ini

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

packages/google-cloud-datastore/noxfile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@
4646
PREVIEW_PYTHON_VERSION = "3.14"
4747

4848
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
49+
# Path to the centralized mypy configuration file at the repository root.
50+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
51+
MYPY_CONFIG_FILE = next(
52+
(
53+
str(p / "mypy.ini")
54+
for p in CURRENT_DIRECTORY.parents
55+
if (p / "mypy.ini").exists()
56+
),
57+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
58+
)
59+
4960

5061
if (CURRENT_DIRECTORY / "testing").exists():
5162
LOWER_BOUND_CONSTRAINTS_FILE = (
@@ -107,6 +118,7 @@ def mypy(session):
107118
session.install(".")
108119
session.run(
109120
"mypy",
121+
f"--config-file={MYPY_CONFIG_FILE}",
110122
"-p",
111123
"google",
112124
# TODO(https://github.com/googleapis/google-cloud-python/issues/16083)

packages/google-cloud-error-reporting/mypy.ini

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

packages/google-cloud-error-reporting/noxfile.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@
4646
PREVIEW_PYTHON_VERSION = "3.14"
4747

4848
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
49+
# Path to the centralized mypy configuration file at the repository root.
50+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
51+
MYPY_CONFIG_FILE = next(
52+
(
53+
str(p / "mypy.ini")
54+
for p in CURRENT_DIRECTORY.parents
55+
if (p / "mypy.ini").exists()
56+
),
57+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
58+
)
59+
4960

5061
if (CURRENT_DIRECTORY / "testing").exists():
5162
LOWER_BOUND_CONSTRAINTS_FILE = (
@@ -107,6 +118,7 @@ def mypy(session):
107118
session.install(".")
108119
session.run(
109120
"mypy",
121+
f"--config-file={MYPY_CONFIG_FILE}",
110122
"-p",
111123
"google",
112124
# TODO(https://github.com/googleapis/google-cloud-python/issues/16083)

packages/google-cloud-firestore/mypy.ini

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

packages/google-cloud-firestore/noxfile.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@
4646
PREVIEW_PYTHON_VERSION = "3.14"
4747

4848
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
49+
# Path to the centralized mypy configuration file at the repository root.
50+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
51+
MYPY_CONFIG_FILE = next(
52+
(
53+
str(p / "mypy.ini")
54+
for p in CURRENT_DIRECTORY.parents
55+
if (p / "mypy.ini").exists()
56+
),
57+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
58+
)
59+
4960

5061
if (CURRENT_DIRECTORY / "testing").exists():
5162
LOWER_BOUND_CONSTRAINTS_FILE = (
@@ -166,9 +177,9 @@ def mypy(session):
166177
session.install(".")
167178
session.run(
168179
"mypy",
180+
f"--config-file={MYPY_CONFIG_FILE}",
169181
"-p",
170182
"google",
171-
"--check-untyped-defs",
172183
*session.posargs,
173184
)
174185

packages/google-cloud-logging/mypy.ini

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

0 commit comments

Comments
 (0)