Skip to content

Commit cd574c9

Browse files
committed
feat(generator): introduce MYPY_CONFIG_FILE constant in templates
1 parent 9b403cb commit cd574c9

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[mypy]
2-
python_version = 3.14
32
namespace_packages = True
43
ignore_missing_imports = False
54

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
{% block content %}
44

55
import os
6+
import pathlib
67

78
import nox # type: ignore
89

910

11+
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
12+
# Path to the centralized mypy configuration file at the repository root.
13+
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
14+
15+
1016
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
1117
# Add tests for Python 3.15 alpha1
1218
# https://peps.python.org/pep-0790/
@@ -44,7 +50,7 @@ def mypy(session):
4450
session.install('.')
4551
session.run(
4652
'mypy',
47-
"--config-file=../../mypy.ini",
53+
f"--config-file={MYPY_CONFIG_FILE}",
4854
{% if api.naming.module_namespace %}
4955
'{{ api.naming.module_namespace[0] }}',
5056
{% else %}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ DEFAULT_PYTHON_VERSION = "3.14"
4040
PREVIEW_PYTHON_VERSION = "3.14"
4141

4242
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
43+
# Path to the centralized mypy configuration file at the repository root.
44+
MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini")
4345

4446
if (CURRENT_DIRECTORY / "testing").exists():
4547
LOWER_BOUND_CONSTRAINTS_FILE = (
@@ -101,7 +103,7 @@ def mypy(session):
101103
session.install(".")
102104
session.run(
103105
"mypy",
104-
"--config-file=../../mypy.ini",
106+
f"--config-file={MYPY_CONFIG_FILE}",
105107
"-p",
106108
{% if api.naming.module_namespace %}
107109
"{{ api.naming.module_namespace[0] }}",

0 commit comments

Comments
 (0)