diff --git a/mypy.ini b/mypy.ini index 05d59c9ea7b0..a8fa4f4ccfb9 100644 --- a/mypy.ini +++ b/mypy.ini @@ -95,14 +95,18 @@ ignore_missing_imports = True ignore_missing_imports = True [mypy-google.cloud.bigtable.*] +# Broadly ignore errors for the older, legacy/handwritten parts of the library ignore_errors = True [mypy-google.cloud.bigtable.data.*] +# Enable strict checks ONLY for the modern data submodule check_untyped_defs = True warn_unreachable = True disallow_any_generics = True +# Do NOT ignore errors in the modern submodule ignore_errors = False + [mypy-google.cloud.bigtable_admin.*] ignore_errors = True diff --git a/packages/google-cloud-spanner/mypy.ini b/packages/google-cloud-spanner/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-spanner/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-spanner/noxfile.py b/packages/google-cloud-spanner/noxfile.py index fa74716b8142..7dcb31b45ed7 100644 --- a/packages/google-cloud-spanner/noxfile.py +++ b/packages/google-cloud-spanner/noxfile.py @@ -69,6 +69,17 @@ SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# Path to the centralized mypy configuration file at the repository root. +# Search upwards to support running nox from both monorepo packages and integration test goldens. +MYPY_CONFIG_FILE = next( + ( + str(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), + str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), +) + nox.options.sessions = [ "unit-3.10", @@ -767,6 +778,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/tests/system/_helpers.py b/packages/google-cloud-spanner/tests/system/_helpers.py index 4cd9879e5d2d..49c8c616709c 100644 --- a/packages/google-cloud-spanner/tests/system/_helpers.py +++ b/packages/google-cloud-spanner/tests/system/_helpers.py @@ -18,9 +18,9 @@ import uuid from google.api_core import exceptions +from google.cloud.spanner_v1 import instance as instance_mod from test_utils import retry -from google.cloud.spanner_v1 import instance as instance_mod from tests import _fixtures CREATE_INSTANCE_ENVVAR = "GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE" diff --git a/packages/google-cloud-spanner/tests/system/conftest.py b/packages/google-cloud-spanner/tests/system/conftest.py index 740cfc0e02b5..f099f3977b58 100644 --- a/packages/google-cloud-spanner/tests/system/conftest.py +++ b/packages/google-cloud-spanner/tests/system/conftest.py @@ -17,7 +17,6 @@ import time import pytest - from google.cloud import spanner_v1 from google.cloud.spanner_admin_database_v1 import DatabaseDialect from google.cloud.spanner_admin_database_v1.types.backup import (