From 91a61670955554b6ac739a86c6243933115343d7 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 9 Jun 2026 14:39:25 -0400 Subject: [PATCH 1/3] feat: centralize mypy config --- mypy.ini | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 mypy.ini diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 000000000000..a5456a18d345 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,94 @@ +[mypy] +python_version = 3.14 +namespace_packages = True +ignore_missing_imports = False + +# Helps mypy navigate the "google" namespace more reliably in 3.10+ +explicit_package_bases = True + +# Performance: reuse results from previous runs to speed up "nox" +incremental = True + +exclude = (?x)( + ^third_party/ + | tests/unit/resources/ + | tests/unit/gapic/ + ) + +# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): +# Dependencies that historically lacks py.typed markers +[mypy-google.iam.*] +ignore_missing_imports = True + +[mypy-google.type.*] +ignore_missing_imports = True + + +# ============================================================================== +# PACKAGE-SPECIFIC OVERRIDES +# ============================================================================== + +# --- google-cloud-core --- +[mypy-google.protobuf.*] +ignore_missing_imports = True + +# --- bigframes --- +[mypy-cloudpickle.*] +ignore_missing_imports = True +[mypy-flask] +ignore_missing_imports = True +[mypy-pydata_google_auth] +ignore_missing_imports = True +[mypy-google.colab] +ignore_missing_imports = True +[mypy-pytz] +ignore_missing_imports = True +[mypy-pyarrow.*] +ignore_missing_imports = True +[mypy-ibis.*] +ignore_missing_imports = True +[mypy-ipywidgets] +ignore_missing_imports = True +[mypy-google.cloud.pubsub] +ignore_missing_imports = True +[mypy-google.cloud.bigtable] +ignore_missing_imports = True +[mypy-anywidget] +ignore_missing_imports = True + +# --- google-cloud-bigtable --- +[mypy-google.cloud.bigtable.*] +check_untyped_defs = True +warn_unreachable = True +disallow_any_generics = True +ignore_errors = True + +[mypy-google.cloud.bigtable.data.*] +ignore_errors = False + +[mypy-grpc.*] +ignore_missing_imports = True +[mypy-google.auth.*] +ignore_missing_imports = True +[mypy-google.longrunning.*] +ignore_missing_imports = True +[mypy-google.oauth2.*] +ignore_missing_imports = True +[mypy-google.rpc.*] +ignore_missing_imports = True +[mypy-proto.*] +ignore_missing_imports = True +[mypy-pytest] +ignore_missing_imports = True + +# --- google-cloud-datastore --- +[mypy-google.cloud.datastore._app_engine_key_pb2] +ignore_errors = True + +# TODO(https://github.com/googleapis/gapic-generator-python/issues/2410): +# Remove once this generator bug is fixed +[mypy-google.cloud.datastore_v1.services.datastore.async_client] +ignore_errors = True + +[mypy-google.cloud.datastore_v1.services.datastore.client] +ignore_errors = True From 1afd309fd99fda58ec7e7b08f6b74af9512772e7 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 9 Jun 2026 14:54:45 -0400 Subject: [PATCH 2/3] feat(handwritten): centralize mypy.ini and update noxfiles --- mypy.ini | 1 - packages/bigframes/mypy.ini | 46 ------------------- packages/bigframes/noxfile.py | 4 ++ packages/bigquery-magics/mypy.ini | 3 -- packages/google-auth/mypy.ini | 3 -- packages/google-auth/noxfile.py | 6 ++- packages/google-backstory/mypy.ini | 15 ------ packages/google-backstory/noxfile.py | 4 ++ .../google-cloud-appengine-logging/mypy.ini | 15 ------ .../google-cloud-appengine-logging/noxfile.py | 4 ++ .../google-cloud-bigquery-logging/mypy.ini | 15 ------ .../google-cloud-bigquery-logging/noxfile.py | 4 ++ packages/google-cloud-common/mypy.ini | 15 ------ packages/google-cloud-common/noxfile.py | 4 ++ packages/google-cloud-core/mypy.ini | 7 --- packages/google-cloud-core/noxfile.py | 11 ++++- packages/google-cloud-iam-logging/mypy.ini | 15 ------ packages/google-cloud-iam-logging/noxfile.py | 4 ++ packages/google-cloud-source-context/mypy.ini | 15 ------ .../google-cloud-source-context/noxfile.py | 4 ++ .../mypy.ini | 15 ------ .../noxfile.py | 4 ++ packages/google-cloud-testutils/mypy.ini | 3 -- packages/google-cloud-testutils/noxfile.py | 6 ++- packages/google-crc32c/mypy.ini | 3 -- packages/google-crc32c/noxfile.py | 9 +++- packages/google-geo-type/mypy.ini | 15 ------ packages/google-geo-type/noxfile.py | 4 ++ packages/google-resumable-media/mypy.ini | 3 -- packages/google-resumable-media/noxfile.py | 6 ++- 30 files changed, 69 insertions(+), 194 deletions(-) delete mode 100644 packages/bigframes/mypy.ini delete mode 100644 packages/bigquery-magics/mypy.ini delete mode 100644 packages/google-auth/mypy.ini delete mode 100644 packages/google-backstory/mypy.ini delete mode 100644 packages/google-cloud-appengine-logging/mypy.ini delete mode 100644 packages/google-cloud-bigquery-logging/mypy.ini delete mode 100644 packages/google-cloud-common/mypy.ini delete mode 100644 packages/google-cloud-core/mypy.ini delete mode 100644 packages/google-cloud-iam-logging/mypy.ini delete mode 100644 packages/google-cloud-source-context/mypy.ini delete mode 100644 packages/google-cloud-spanner-dbapi-driver/mypy.ini delete mode 100644 packages/google-cloud-testutils/mypy.ini delete mode 100644 packages/google-crc32c/mypy.ini delete mode 100644 packages/google-geo-type/mypy.ini delete mode 100644 packages/google-resumable-media/mypy.ini diff --git a/mypy.ini b/mypy.ini index a5456a18d345..e8d3405ef0ac 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,4 @@ [mypy] -python_version = 3.14 namespace_packages = True ignore_missing_imports = False diff --git a/packages/bigframes/mypy.ini b/packages/bigframes/mypy.ini deleted file mode 100644 index 7709eb200a35..000000000000 --- a/packages/bigframes/mypy.ini +++ /dev/null @@ -1,46 +0,0 @@ -# https://mypy.readthedocs.io/en/stable/config_file.html#config-file - -[mypy] -exclude = ^third_party/ - -[mypy-google.auth.*] -ignore_missing_imports = True - -[mypy-cloudpickle.*] -ignore_missing_imports = True - -[mypy-flask] -ignore_missing_imports = True - -[mypy-pydata_google_auth] -ignore_missing_imports = True - -[mypy-google.colab] -ignore_missing_imports = True - -[mypy-google.iam.*] -ignore_missing_imports = True - -[mypy-pytz] -ignore_missing_imports = True - -[mypy-pyarrow] -ignore_missing_imports = True - -[mypy-ibis.*] -ignore_missing_imports = True - -[mypy-ipywidgets] -ignore_missing_imports = True - -[mypy-pyarrow.feather] -ignore_missing_imports = True - -[mypy-google.cloud.pubsub] -ignore_missing_imports = True - -[mypy-google.cloud.bigtable] -ignore_missing_imports = True - -[mypy-anywidget] -ignore_missing_imports = True diff --git a/packages/bigframes/noxfile.py b/packages/bigframes/noxfile.py index 7ba8f04d4075..09344f91b1ee 100644 --- a/packages/bigframes/noxfile.py +++ b/packages/bigframes/noxfile.py @@ -114,6 +114,9 @@ LOGGING_NAME_ENV_VAR = "BIGFRAMES_PERFORMANCE_LOG_NAME" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + # Sessions are executed in the order so putting the smaller sessions # ahead to fail fast at presubmit running. @@ -1086,6 +1089,7 @@ def mypy(session): shutil.rmtree(".mypy_cache", ignore_errors=True) session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "bigframes", os.path.join("tests", "system"), os.path.join("tests", "unit"), diff --git a/packages/bigquery-magics/mypy.ini b/packages/bigquery-magics/mypy.ini deleted file mode 100644 index a3cb5c292172..000000000000 --- a/packages/bigquery-magics/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True diff --git a/packages/google-auth/mypy.ini b/packages/google-auth/mypy.ini deleted file mode 100644 index c129006db138..000000000000 --- a/packages/google-auth/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.9 -namespace_packages = True diff --git a/packages/google-auth/noxfile.py b/packages/google-auth/noxfile.py index 5962f96bf094..0cc79331cac5 100644 --- a/packages/google-auth/noxfile.py +++ b/packages/google-auth/noxfile.py @@ -20,6 +20,9 @@ import nox CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + CLICK_VERSION = "click" BLACK_VERSION = "black==23.7.0" @@ -156,7 +159,8 @@ def mypy(session): "types-mock", "pytest<8.0.0", ) - session.run("mypy", "-p", "google", "-p", "tests", "-p", "tests_async") + session.run("mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "-p", "tests", "-p", "tests_async") @nox.session(python=ALL_PYTHON) diff --git a/packages/google-backstory/mypy.ini b/packages/google-backstory/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-backstory/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-backstory/noxfile.py b/packages/google-backstory/noxfile.py index 44eaafe8e0f6..e5bffc1a792d 100644 --- a/packages/google-backstory/noxfile.py +++ b/packages/google-backstory/noxfile.py @@ -46,6 +46,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +110,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-cloud-appengine-logging/mypy.ini b/packages/google-cloud-appengine-logging/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-appengine-logging/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-cloud-appengine-logging/noxfile.py b/packages/google-cloud-appengine-logging/noxfile.py index 9d295bb84faa..7cfafde7126e 100644 --- a/packages/google-cloud-appengine-logging/noxfile.py +++ b/packages/google-cloud-appengine-logging/noxfile.py @@ -46,6 +46,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +110,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-cloud-bigquery-logging/mypy.ini b/packages/google-cloud-bigquery-logging/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-bigquery-logging/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-cloud-bigquery-logging/noxfile.py b/packages/google-cloud-bigquery-logging/noxfile.py index 357903bd6d52..3e352e32c706 100644 --- a/packages/google-cloud-bigquery-logging/noxfile.py +++ b/packages/google-cloud-bigquery-logging/noxfile.py @@ -46,6 +46,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +110,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-cloud-common/mypy.ini b/packages/google-cloud-common/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-common/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-cloud-common/noxfile.py b/packages/google-cloud-common/noxfile.py index 58d097ef35dc..0a061201495e 100644 --- a/packages/google-cloud-common/noxfile.py +++ b/packages/google-cloud-common/noxfile.py @@ -46,6 +46,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +110,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-cloud-core/mypy.ini b/packages/google-cloud-core/mypy.ini deleted file mode 100644 index ed9dccd3b6fd..000000000000 --- a/packages/google-cloud-core/mypy.ini +++ /dev/null @@ -1,7 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = True - -[mypy-google.protobuf] -ignore_missing_imports = True diff --git a/packages/google-cloud-core/noxfile.py b/packages/google-cloud-core/noxfile.py index 2de40dfb9234..66a8450e844f 100644 --- a/packages/google-cloud-core/noxfile.py +++ b/packages/google-cloud-core/noxfile.py @@ -33,6 +33,8 @@ "3.14", ] CURRENT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = os.path.join(os.path.dirname(os.path.dirname(CURRENT_DIRECTORY)), "mypy.ini") # Error if a python version is missing nox.options.error_on_missing_interpreters = True @@ -62,7 +64,14 @@ def mypy(session): "types-mock", "types-protobuf!=4.24.0.20240106", ) - session.run("mypy", "-p", "google", "-p", "tests") + session.run( + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", + "-p", + "google", + "-p", + "tests", + ) @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/google-cloud-iam-logging/mypy.ini b/packages/google-cloud-iam-logging/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-iam-logging/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-cloud-iam-logging/noxfile.py b/packages/google-cloud-iam-logging/noxfile.py index eb1274b44083..60682d6a3bb7 100644 --- a/packages/google-cloud-iam-logging/noxfile.py +++ b/packages/google-cloud-iam-logging/noxfile.py @@ -46,6 +46,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +110,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-cloud-source-context/mypy.ini b/packages/google-cloud-source-context/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-source-context/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-cloud-source-context/noxfile.py b/packages/google-cloud-source-context/noxfile.py index 6488b4a11907..d2d0f984390b 100644 --- a/packages/google-cloud-source-context/noxfile.py +++ b/packages/google-cloud-source-context/noxfile.py @@ -46,6 +46,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +110,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-cloud-spanner-dbapi-driver/mypy.ini b/packages/google-cloud-spanner-dbapi-driver/mypy.ini deleted file mode 100644 index 81b11c94badc..000000000000 --- a/packages/google-cloud-spanner-dbapi-driver/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.11 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-cloud-spanner-dbapi-driver/noxfile.py b/packages/google-cloud-spanner-dbapi-driver/noxfile.py index 2fedee7ee5af..1a25df140b7c 100644 --- a/packages/google-cloud-spanner-dbapi-driver/noxfile.py +++ b/packages/google-cloud-spanner-dbapi-driver/noxfile.py @@ -53,6 +53,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" PACKAGE_NAME = "google-cloud-spanner-dbapi-driver" @@ -115,6 +118,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", ) diff --git a/packages/google-cloud-testutils/mypy.ini b/packages/google-cloud-testutils/mypy.ini deleted file mode 100644 index 569486a9ce60..000000000000 --- a/packages/google-cloud-testutils/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.10 -exclude = tests/unit/resources/ diff --git a/packages/google-cloud-testutils/noxfile.py b/packages/google-cloud-testutils/noxfile.py index 0e86a298190e..24ceb506dbae 100644 --- a/packages/google-cloud-testutils/noxfile.py +++ b/packages/google-cloud-testutils/noxfile.py @@ -39,6 +39,9 @@ RUFF_VERSION = "ruff==0.14.14" BLACK_PATHS = ["test_utils", "setup.py"] CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + @nox.session(python=DEFAULT_PYTHON_VERSION) @@ -113,7 +116,8 @@ def mypy(session): "types-mock", "types-setuptools", ) - session.run("mypy", "test_utils/", "tests/") + session.run("mypy", + f"--config-file={MYPY_CONFIG_FILE}", "test_utils/", "tests/") @nox.session(python=ALL_PYTHON) diff --git a/packages/google-crc32c/mypy.ini b/packages/google-crc32c/mypy.ini deleted file mode 100644 index 569486a9ce60..000000000000 --- a/packages/google-crc32c/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.10 -exclude = tests/unit/resources/ diff --git a/packages/google-crc32c/noxfile.py b/packages/google-crc32c/noxfile.py index b44c502ccd0c..4759c1fa0c32 100644 --- a/packages/google-crc32c/noxfile.py +++ b/packages/google-crc32c/noxfile.py @@ -22,6 +22,8 @@ import nox HERE = os.path.dirname(__file__) +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(HERE))), "mypy.ini") # Constants DEFAULT_PYTHON_VERSION = "3.14" @@ -84,7 +86,12 @@ def mypy(session): "types-setuptools", ) session.env["MYPYPATH"] = "src" - session.run("mypy", "src/google_crc32c/", "tests/") + session.run( + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", + "src/google_crc32c/", + "tests/", + ) @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/google-geo-type/mypy.ini b/packages/google-geo-type/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-geo-type/mypy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -ignore_missing_imports = False - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563): -# Dependencies that historically lacks py.typed markers -[mypy-google.iam.*] -ignore_missing_imports = True - -# Helps mypy navigate the 'google' namespace more reliably in 3.10+ -explicit_package_bases = True - -# Performance: reuse results from previous runs to speed up 'nox' -incremental = True diff --git a/packages/google-geo-type/noxfile.py b/packages/google-geo-type/noxfile.py index c7dd9bef9aaa..b44ad6cb88e6 100644 --- a/packages/google-geo-type/noxfile.py +++ b/packages/google-geo-type/noxfile.py @@ -46,6 +46,9 @@ PREVIEW_PYTHON_VERSION = "3.14" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +110,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-resumable-media/mypy.ini b/packages/google-resumable-media/mypy.ini deleted file mode 100644 index 4505b485436b..000000000000 --- a/packages/google-resumable-media/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.6 -namespace_packages = True diff --git a/packages/google-resumable-media/noxfile.py b/packages/google-resumable-media/noxfile.py index a1c1ae199709..9fb57f47b183 100644 --- a/packages/google-resumable-media/noxfile.py +++ b/packages/google-resumable-media/noxfile.py @@ -21,6 +21,9 @@ import nox CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +MYPY_CONFIG_FILE = str(CURRENT_DIRECTORY.parent.parent / "mypy.ini") + SYSTEM_TEST_ENV_VARS = ("GOOGLE_APPLICATION_CREDENTIALS",) RUFF_VERSION = "ruff==0.14.14" @@ -251,7 +254,8 @@ def mypy(session): "types-requests", "types-mock", ) - session.run("mypy", "-p", "google", "-p", "tests", "-p", "tests_async") + session.run("mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "-p", "tests", "-p", "tests_async") @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) From 8dd966109bc91d93a4d2ad64808eeeddccb35af2 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 9 Jun 2026 15:58:25 -0400 Subject: [PATCH 3/3] style(mypy): format modified noxfile.py files with black --- packages/google-auth/noxfile.py | 12 ++++++++++-- packages/google-crc32c/noxfile.py | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/google-auth/noxfile.py b/packages/google-auth/noxfile.py index 0cc79331cac5..cd1b1e5e1a2d 100644 --- a/packages/google-auth/noxfile.py +++ b/packages/google-auth/noxfile.py @@ -159,8 +159,16 @@ def mypy(session): "types-mock", "pytest<8.0.0", ) - session.run("mypy", - f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "-p", "tests", "-p", "tests_async") + session.run( + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", + "-p", + "google", + "-p", + "tests", + "-p", + "tests_async", + ) @nox.session(python=ALL_PYTHON) diff --git a/packages/google-crc32c/noxfile.py b/packages/google-crc32c/noxfile.py index 4759c1fa0c32..af48c7ab282d 100644 --- a/packages/google-crc32c/noxfile.py +++ b/packages/google-crc32c/noxfile.py @@ -23,7 +23,9 @@ HERE = os.path.dirname(__file__) # Path to the centralized mypy configuration file at the repository root. -MYPY_CONFIG_FILE = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(HERE))), "mypy.ini") +MYPY_CONFIG_FILE = os.path.join( + os.path.dirname(os.path.dirname(os.path.abspath(HERE))), "mypy.ini" +) # Constants DEFAULT_PYTHON_VERSION = "3.14"