Skip to content

Commit 179d905

Browse files
committed
fix(mypy): resolve mypy.ini location in integration test goldens
1 parent 79ef976 commit 179d905

10 files changed

Lines changed: 50 additions & 10 deletions

File tree

packages/gapic-generator/gapic/ads-templates/noxfile.py.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import pathlib
88
import nox # type: ignore
99

1010
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
11-
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
11+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
12+
MYPY_CONFIG_FILE = next(
13+
(str(p / "mypy.ini") for p in CURRENT_DIRECTORY.parents if (p / "mypy.ini").exists()),
14+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
15+
)
1216

1317

1418
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):

packages/gapic-generator/gapic/templates/noxfile.py.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ PREVIEW_PYTHON_VERSION = "3.14"
4141

4242
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
4343
# Path to the centralized mypy configuration file at the repository root.
44-
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
44+
# Search upwards to support running nox from both monorepo packages and integration test goldens.
45+
MYPY_CONFIG_FILE = next(
46+
(str(p / "mypy.ini") for p in CURRENT_DIRECTORY.parents if (p / "mypy.ini").exists()),
47+
str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"),
48+
)
4549

4650
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
4751
PACKAGE_NAME = "{{ api.naming.warehouse_package_name }}"

packages/gapic-generator/tests/integration/goldens/asset/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-cloud-asset"

packages/gapic-generator/tests/integration/goldens/credentials/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-iam-credentials"

packages/gapic-generator/tests/integration/goldens/eventarc/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-cloud-eventarc"

packages/gapic-generator/tests/integration/goldens/logging/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-cloud-logging"

packages/gapic-generator/tests/integration/goldens/logging_internal/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-cloud-logging"

packages/gapic-generator/tests/integration/goldens/redis/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-cloud-redis"

packages/gapic-generator/tests/integration/goldens/redis_selective/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-cloud-redis"

packages/gapic-generator/tests/integration/goldens/storagebatchoperations/noxfile.py

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

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

5357
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
5458
PACKAGE_NAME = "google-cloud-storagebatchoperations"

0 commit comments

Comments
 (0)