Skip to content

Commit 19fb692

Browse files
committed
fix(handwritten): use dynamic parent-directory traversal for mypy.ini in noxfiles
1 parent e77cd19 commit 19fb692

13 files changed

Lines changed: 68 additions & 16 deletions

File tree

packages/bigframes/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@
115115

116116
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
117117
# Path to the centralized mypy configuration file at the repository root.
118-
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
118+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
119+
MYPY_CONFIG_FILE = next(
120+
(str(p / "mypy.ini") for p in CURRENT_DIRECTORY.parents if (p / "mypy.ini").exists()),
121+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
122+
)
119123

120124

121125
# Sessions are executed in the order so putting the smaller sessions

packages/google-auth/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121

2222
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
2323
# Path to the centralized mypy configuration file at the repository root.
24-
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
24+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
25+
MYPY_CONFIG_FILE = next(
26+
(str(p / "mypy.ini") for p in CURRENT_DIRECTORY.parents if (p / "mypy.ini").exists()),
27+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
28+
)
2529

2630

2731
CLICK_VERSION = "click"

packages/google-cloud-appengine-logging/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747

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

5256

5357
if (CURRENT_DIRECTORY / "testing").exists():

packages/google-cloud-bigquery-logging/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747

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

5256

5357
if (CURRENT_DIRECTORY / "testing").exists():

packages/google-cloud-common/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747

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

5256

5357
if (CURRENT_DIRECTORY / "testing").exists():

packages/google-cloud-core/noxfile.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from __future__ import absolute_import
1616

1717
import os
18+
import pathlib
1819
import re
1920
import shutil
2021

@@ -32,9 +33,13 @@
3233
"3.13",
3334
"3.14",
3435
]
35-
CURRENT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
36+
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
3637
# Path to the centralized mypy configuration file at the repository root.
37-
MYPY_CONFIG_FILE = os.path.join(os.path.dirname(os.path.dirname(CURRENT_DIRECTORY)), "mypy.ini")
38+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
39+
MYPY_CONFIG_FILE = next(
40+
(str(p / "mypy.ini") for p in CURRENT_DIRECTORY.parents if (p / "mypy.ini").exists()),
41+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
42+
)
3843

3944
# Error if a python version is missing
4045
nox.options.error_on_missing_interpreters = True

packages/google-cloud-iam-logging/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747

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

5256

5357
if (CURRENT_DIRECTORY / "testing").exists():

packages/google-cloud-source-context/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@
4747

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

5256

5357
if (CURRENT_DIRECTORY / "testing").exists():

packages/google-cloud-spanner-dbapi-driver/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@
5454

5555
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
5656
# Path to the centralized mypy configuration file at the repository root.
57-
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
57+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
58+
MYPY_CONFIG_FILE = next(
59+
(str(p / "mypy.ini") for p in CURRENT_DIRECTORY.parents if (p / "mypy.ini").exists()),
60+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
61+
)
5862

5963

6064
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"

packages/google-cloud-testutils/noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
BLACK_PATHS = ["test_utils", "setup.py"]
4141
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
4242
# Path to the centralized mypy configuration file at the repository root.
43-
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
43+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
44+
MYPY_CONFIG_FILE = next(
45+
(str(p / "mypy.ini") for p in CURRENT_DIRECTORY.parents if (p / "mypy.ini").exists()),
46+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
47+
)
4448

4549

4650

0 commit comments

Comments
 (0)