From bedd2f230c7b07943a1def47e1db67ca44943f95 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 9 Jun 2026 14:54:45 -0400 Subject: [PATCH 01/18] feat(handwritten): centralize mypy.ini and update noxfiles --- mypy.ini | 5 ++ packages/bigframes/mypy.ini | 49 ------------------- 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, 74 insertions(+), 196 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 e36c23ebbc8a..6da7761d9aa0 100644 --- a/mypy.ini +++ b/mypy.ini @@ -97,4 +97,9 @@ warn_unreachable = True disallow_any_generics = True ignore_errors = False +# --- bigframes --- +[mypy-bigframes_vendored.*] +ignore_errors = True + + diff --git a/packages/bigframes/mypy.ini b/packages/bigframes/mypy.ini deleted file mode 100644 index e3f44c262ac6..000000000000 --- a/packages/bigframes/mypy.ini +++ /dev/null @@ -1,49 +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 - -[mypy-bigframes_vendored.*] -ignore_errors = True diff --git a/packages/bigframes/noxfile.py b/packages/bigframes/noxfile.py index 0a33264aa8ea..0acf2294f44a 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. @@ -1085,6 +1088,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 d449d71f273c185fde32858979f9e2790e3f8546 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 9 Jun 2026 15:58:25 -0400 Subject: [PATCH 02/18] 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" From 15b1b644b8d11459be5262543d9aaf7435755470 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 23 Jun 2026 15:33:03 -0400 Subject: [PATCH 03/18] fix(handwritten): use dynamic parent-directory traversal for mypy.ini in noxfiles --- packages/bigframes/noxfile.py | 6 +++++- packages/google-auth/noxfile.py | 6 +++++- packages/google-cloud-appengine-logging/noxfile.py | 6 +++++- packages/google-cloud-bigquery-logging/noxfile.py | 6 +++++- packages/google-cloud-common/noxfile.py | 6 +++++- packages/google-cloud-core/noxfile.py | 9 +++++++-- packages/google-cloud-iam-logging/noxfile.py | 6 +++++- packages/google-cloud-source-context/noxfile.py | 6 +++++- packages/google-cloud-spanner-dbapi-driver/noxfile.py | 6 +++++- packages/google-cloud-testutils/noxfile.py | 6 +++++- packages/google-crc32c/noxfile.py | 9 ++++++--- packages/google-geo-type/noxfile.py | 6 +++++- packages/google-resumable-media/noxfile.py | 6 +++++- 13 files changed, 68 insertions(+), 16 deletions(-) diff --git a/packages/bigframes/noxfile.py b/packages/bigframes/noxfile.py index 0acf2294f44a..015c841f91ec 100644 --- a/packages/bigframes/noxfile.py +++ b/packages/bigframes/noxfile.py @@ -115,7 +115,11 @@ 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") +# 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"), +) # Sessions are executed in the order so putting the smaller sessions diff --git a/packages/google-auth/noxfile.py b/packages/google-auth/noxfile.py index cd1b1e5e1a2d..fb3c2ddd7810 100644 --- a/packages/google-auth/noxfile.py +++ b/packages/google-auth/noxfile.py @@ -21,7 +21,11 @@ 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") +# 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"), +) CLICK_VERSION = "click" diff --git a/packages/google-cloud-appengine-logging/noxfile.py b/packages/google-cloud-appengine-logging/noxfile.py index 7cfafde7126e..285ae03c007b 100644 --- a/packages/google-cloud-appengine-logging/noxfile.py +++ b/packages/google-cloud-appengine-logging/noxfile.py @@ -47,7 +47,11 @@ 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") +# 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"), +) if (CURRENT_DIRECTORY / "testing").exists(): diff --git a/packages/google-cloud-bigquery-logging/noxfile.py b/packages/google-cloud-bigquery-logging/noxfile.py index 3e352e32c706..233565d000b0 100644 --- a/packages/google-cloud-bigquery-logging/noxfile.py +++ b/packages/google-cloud-bigquery-logging/noxfile.py @@ -47,7 +47,11 @@ 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") +# 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"), +) if (CURRENT_DIRECTORY / "testing").exists(): diff --git a/packages/google-cloud-common/noxfile.py b/packages/google-cloud-common/noxfile.py index 0a061201495e..adf65e208000 100644 --- a/packages/google-cloud-common/noxfile.py +++ b/packages/google-cloud-common/noxfile.py @@ -47,7 +47,11 @@ 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") +# 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"), +) if (CURRENT_DIRECTORY / "testing").exists(): diff --git a/packages/google-cloud-core/noxfile.py b/packages/google-cloud-core/noxfile.py index 66a8450e844f..1bace87ad902 100644 --- a/packages/google-cloud-core/noxfile.py +++ b/packages/google-cloud-core/noxfile.py @@ -15,6 +15,7 @@ from __future__ import absolute_import import os +import pathlib import re import shutil @@ -32,9 +33,13 @@ "3.13", "3.14", ] -CURRENT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() # 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") +# 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"), +) # Error if a python version is missing nox.options.error_on_missing_interpreters = True diff --git a/packages/google-cloud-iam-logging/noxfile.py b/packages/google-cloud-iam-logging/noxfile.py index 60682d6a3bb7..ee0274f50323 100644 --- a/packages/google-cloud-iam-logging/noxfile.py +++ b/packages/google-cloud-iam-logging/noxfile.py @@ -47,7 +47,11 @@ 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") +# 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"), +) if (CURRENT_DIRECTORY / "testing").exists(): diff --git a/packages/google-cloud-source-context/noxfile.py b/packages/google-cloud-source-context/noxfile.py index d2d0f984390b..4a8aa5de2168 100644 --- a/packages/google-cloud-source-context/noxfile.py +++ b/packages/google-cloud-source-context/noxfile.py @@ -47,7 +47,11 @@ 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") +# 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"), +) if (CURRENT_DIRECTORY / "testing").exists(): diff --git a/packages/google-cloud-spanner-dbapi-driver/noxfile.py b/packages/google-cloud-spanner-dbapi-driver/noxfile.py index 1a25df140b7c..a3395cc3a349 100644 --- a/packages/google-cloud-spanner-dbapi-driver/noxfile.py +++ b/packages/google-cloud-spanner-dbapi-driver/noxfile.py @@ -54,7 +54,11 @@ 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") +# 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"), +) LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" diff --git a/packages/google-cloud-testutils/noxfile.py b/packages/google-cloud-testutils/noxfile.py index 24ceb506dbae..7716dd6c4d2d 100644 --- a/packages/google-cloud-testutils/noxfile.py +++ b/packages/google-cloud-testutils/noxfile.py @@ -40,7 +40,11 @@ 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") +# 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"), +) diff --git a/packages/google-crc32c/noxfile.py b/packages/google-crc32c/noxfile.py index af48c7ab282d..bb664f07782b 100644 --- a/packages/google-crc32c/noxfile.py +++ b/packages/google-crc32c/noxfile.py @@ -17,14 +17,17 @@ # Generated by synthtool. DO NOT EDIT! import os +import pathlib import sys import nox -HERE = os.path.dirname(__file__) +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() # 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" +# 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"), ) # Constants diff --git a/packages/google-geo-type/noxfile.py b/packages/google-geo-type/noxfile.py index b44ad6cb88e6..ce73bb6c0465 100644 --- a/packages/google-geo-type/noxfile.py +++ b/packages/google-geo-type/noxfile.py @@ -47,7 +47,11 @@ 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") +# 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"), +) if (CURRENT_DIRECTORY / "testing").exists(): diff --git a/packages/google-resumable-media/noxfile.py b/packages/google-resumable-media/noxfile.py index 9fb57f47b183..3ad5b9fd948b 100644 --- a/packages/google-resumable-media/noxfile.py +++ b/packages/google-resumable-media/noxfile.py @@ -22,7 +22,11 @@ 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") +# 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"), +) SYSTEM_TEST_ENV_VARS = ("GOOGLE_APPLICATION_CREDENTIALS",) From 9defb81692187967df2c6cb6ec02769273b0eed1 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 23 Jun 2026 16:08:49 -0400 Subject: [PATCH 04/18] style(handwritten): format modified noxfiles according to style guide --- packages/bigframes/noxfile.py | 6 +++++- packages/google-auth/noxfile.py | 6 +++++- packages/google-cloud-appengine-logging/noxfile.py | 6 +++++- packages/google-cloud-bigquery-logging/noxfile.py | 6 +++++- packages/google-cloud-common/noxfile.py | 6 +++++- packages/google-cloud-core/noxfile.py | 6 +++++- packages/google-cloud-iam-logging/noxfile.py | 6 +++++- packages/google-cloud-source-context/noxfile.py | 6 +++++- packages/google-cloud-spanner-dbapi-driver/noxfile.py | 6 +++++- packages/google-crc32c/noxfile.py | 6 +++++- packages/google-geo-type/noxfile.py | 6 +++++- 11 files changed, 55 insertions(+), 11 deletions(-) diff --git a/packages/bigframes/noxfile.py b/packages/bigframes/noxfile.py index 015c841f91ec..4b2483f5c9a0 100644 --- a/packages/bigframes/noxfile.py +++ b/packages/bigframes/noxfile.py @@ -117,7 +117,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-auth/noxfile.py b/packages/google-auth/noxfile.py index fb3c2ddd7810..a7a2bf17e1de 100644 --- a/packages/google-auth/noxfile.py +++ b/packages/google-auth/noxfile.py @@ -23,7 +23,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-cloud-appengine-logging/noxfile.py b/packages/google-cloud-appengine-logging/noxfile.py index 285ae03c007b..9e40de8d1472 100644 --- a/packages/google-cloud-appengine-logging/noxfile.py +++ b/packages/google-cloud-appengine-logging/noxfile.py @@ -49,7 +49,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-cloud-bigquery-logging/noxfile.py b/packages/google-cloud-bigquery-logging/noxfile.py index 233565d000b0..b4b999ea8a14 100644 --- a/packages/google-cloud-bigquery-logging/noxfile.py +++ b/packages/google-cloud-bigquery-logging/noxfile.py @@ -49,7 +49,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-cloud-common/noxfile.py b/packages/google-cloud-common/noxfile.py index adf65e208000..f591c50063f4 100644 --- a/packages/google-cloud-common/noxfile.py +++ b/packages/google-cloud-common/noxfile.py @@ -49,7 +49,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-cloud-core/noxfile.py b/packages/google-cloud-core/noxfile.py index 1bace87ad902..a86e71252c69 100644 --- a/packages/google-cloud-core/noxfile.py +++ b/packages/google-cloud-core/noxfile.py @@ -37,7 +37,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-cloud-iam-logging/noxfile.py b/packages/google-cloud-iam-logging/noxfile.py index ee0274f50323..59edeb7b361a 100644 --- a/packages/google-cloud-iam-logging/noxfile.py +++ b/packages/google-cloud-iam-logging/noxfile.py @@ -49,7 +49,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-cloud-source-context/noxfile.py b/packages/google-cloud-source-context/noxfile.py index 4a8aa5de2168..3328e26ef35e 100644 --- a/packages/google-cloud-source-context/noxfile.py +++ b/packages/google-cloud-source-context/noxfile.py @@ -49,7 +49,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-cloud-spanner-dbapi-driver/noxfile.py b/packages/google-cloud-spanner-dbapi-driver/noxfile.py index a3395cc3a349..6eb00ef8a6b6 100644 --- a/packages/google-cloud-spanner-dbapi-driver/noxfile.py +++ b/packages/google-cloud-spanner-dbapi-driver/noxfile.py @@ -56,7 +56,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-crc32c/noxfile.py b/packages/google-crc32c/noxfile.py index bb664f07782b..7b0643a502b0 100644 --- a/packages/google-crc32c/noxfile.py +++ b/packages/google-crc32c/noxfile.py @@ -26,7 +26,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) diff --git a/packages/google-geo-type/noxfile.py b/packages/google-geo-type/noxfile.py index ce73bb6c0465..b14318c5c426 100644 --- a/packages/google-geo-type/noxfile.py +++ b/packages/google-geo-type/noxfile.py @@ -49,7 +49,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) From b1456a6b232d2ca897467f141f2c121a70ae183b Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Thu, 25 Jun 2026 14:33:13 -0400 Subject: [PATCH 05/18] chore: restore mypy.ini and noxfile.py for google-crc32c --- packages/google-crc32c/mypy.ini | 3 +++ packages/google-crc32c/noxfile.py | 20 ++------------------ 2 files changed, 5 insertions(+), 18 deletions(-) create mode 100644 packages/google-crc32c/mypy.ini diff --git a/packages/google-crc32c/mypy.ini b/packages/google-crc32c/mypy.ini new file mode 100644 index 000000000000..569486a9ce60 --- /dev/null +++ b/packages/google-crc32c/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.10 +exclude = tests/unit/resources/ diff --git a/packages/google-crc32c/noxfile.py b/packages/google-crc32c/noxfile.py index 7b0643a502b0..b44c502ccd0c 100644 --- a/packages/google-crc32c/noxfile.py +++ b/packages/google-crc32c/noxfile.py @@ -17,22 +17,11 @@ # Generated by synthtool. DO NOT EDIT! import os -import pathlib import sys import nox -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"), -) +HERE = os.path.dirname(__file__) # Constants DEFAULT_PYTHON_VERSION = "3.14" @@ -95,12 +84,7 @@ def mypy(session): "types-setuptools", ) session.env["MYPYPATH"] = "src" - session.run( - "mypy", - f"--config-file={MYPY_CONFIG_FILE}", - "src/google_crc32c/", - "tests/", - ) + session.run("mypy", "src/google_crc32c/", "tests/") @nox.session(python=DEFAULT_PYTHON_VERSION) From 234bd933dc569400c47357c996bbd5cfd9566b30 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 30 Jun 2026 09:39:12 -0400 Subject: [PATCH 06/18] chore: removes blank spaces from file --- mypy.ini | 3 --- 1 file changed, 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index 6da7761d9aa0..5cf75c85794f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -100,6 +100,3 @@ ignore_errors = False # --- bigframes --- [mypy-bigframes_vendored.*] ignore_errors = True - - - From b520bb743c7009ef90febe05c5b4c736f6b9592e Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 30 Jun 2026 12:37:45 -0400 Subject: [PATCH 07/18] chore: restores bigframes files due to system test issues --- packages/bigframes/mypy.ini | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 packages/bigframes/mypy.ini diff --git a/packages/bigframes/mypy.ini b/packages/bigframes/mypy.ini new file mode 100644 index 000000000000..e3f44c262ac6 --- /dev/null +++ b/packages/bigframes/mypy.ini @@ -0,0 +1,49 @@ +# 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 + +[mypy-bigframes_vendored.*] +ignore_errors = True From bda8f954d2af79bbbde9b81e33b9a79707ba778f Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 30 Jun 2026 12:38:52 -0400 Subject: [PATCH 08/18] chore: restores bigframes files due to system test issues --- packages/bigframes/noxfile.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/bigframes/noxfile.py b/packages/bigframes/noxfile.py index 4b2483f5c9a0..0a33264aa8ea 100644 --- a/packages/bigframes/noxfile.py +++ b/packages/bigframes/noxfile.py @@ -114,17 +114,6 @@ 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. -# 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"), -) - # Sessions are executed in the order so putting the smaller sessions # ahead to fail fast at presubmit running. @@ -1096,7 +1085,6 @@ 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"), From 5fada6e7b673f9c45a530bbfdd2e700709ee7a6a Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 30 Jun 2026 13:48:51 -0400 Subject: [PATCH 09/18] chore: revert changes for overreaching generated packages --- packages/google-backstory/mypy.ini | 15 +++++++++++++++ packages/google-backstory/noxfile.py | 4 ---- packages/google-cloud-appengine-logging/mypy.ini | 15 +++++++++++++++ .../google-cloud-appengine-logging/noxfile.py | 12 ------------ packages/google-cloud-bigquery-logging/mypy.ini | 15 +++++++++++++++ packages/google-cloud-bigquery-logging/noxfile.py | 12 ------------ packages/google-cloud-common/mypy.ini | 15 +++++++++++++++ packages/google-cloud-common/noxfile.py | 12 ------------ packages/google-cloud-iam-logging/mypy.ini | 15 +++++++++++++++ packages/google-cloud-iam-logging/noxfile.py | 12 ------------ packages/google-cloud-source-context/mypy.ini | 15 +++++++++++++++ packages/google-cloud-source-context/noxfile.py | 12 ------------ packages/google-geo-type/mypy.ini | 15 +++++++++++++++ packages/google-geo-type/noxfile.py | 12 ------------ 14 files changed, 105 insertions(+), 76 deletions(-) create mode 100644 packages/google-backstory/mypy.ini create mode 100644 packages/google-cloud-appengine-logging/mypy.ini create mode 100644 packages/google-cloud-bigquery-logging/mypy.ini create mode 100644 packages/google-cloud-common/mypy.ini create mode 100644 packages/google-cloud-iam-logging/mypy.ini create mode 100644 packages/google-cloud-source-context/mypy.ini create mode 100644 packages/google-geo-type/mypy.ini diff --git a/packages/google-backstory/mypy.ini b/packages/google-backstory/mypy.ini new file mode 100644 index 000000000000..e0e0da2e9e40 --- /dev/null +++ b/packages/google-backstory/mypy.ini @@ -0,0 +1,15 @@ +[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 e5bffc1a792d..44eaafe8e0f6 100644 --- a/packages/google-backstory/noxfile.py +++ b/packages/google-backstory/noxfile.py @@ -46,9 +46,6 @@ 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 = ( @@ -110,7 +107,6 @@ 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 new file mode 100644 index 000000000000..e0e0da2e9e40 --- /dev/null +++ b/packages/google-cloud-appengine-logging/mypy.ini @@ -0,0 +1,15 @@ +[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 9e40de8d1472..9d295bb84faa 100644 --- a/packages/google-cloud-appengine-logging/noxfile.py +++ b/packages/google-cloud-appengine-logging/noxfile.py @@ -46,17 +46,6 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), -) - if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -118,7 +107,6 @@ 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 new file mode 100644 index 000000000000..e0e0da2e9e40 --- /dev/null +++ b/packages/google-cloud-bigquery-logging/mypy.ini @@ -0,0 +1,15 @@ +[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 b4b999ea8a14..357903bd6d52 100644 --- a/packages/google-cloud-bigquery-logging/noxfile.py +++ b/packages/google-cloud-bigquery-logging/noxfile.py @@ -46,17 +46,6 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), -) - if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -118,7 +107,6 @@ 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 new file mode 100644 index 000000000000..e0e0da2e9e40 --- /dev/null +++ b/packages/google-cloud-common/mypy.ini @@ -0,0 +1,15 @@ +[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 f591c50063f4..58d097ef35dc 100644 --- a/packages/google-cloud-common/noxfile.py +++ b/packages/google-cloud-common/noxfile.py @@ -46,17 +46,6 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), -) - if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -118,7 +107,6 @@ 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-iam-logging/mypy.ini b/packages/google-cloud-iam-logging/mypy.ini new file mode 100644 index 000000000000..e0e0da2e9e40 --- /dev/null +++ b/packages/google-cloud-iam-logging/mypy.ini @@ -0,0 +1,15 @@ +[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 59edeb7b361a..eb1274b44083 100644 --- a/packages/google-cloud-iam-logging/noxfile.py +++ b/packages/google-cloud-iam-logging/noxfile.py @@ -46,17 +46,6 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), -) - if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -118,7 +107,6 @@ 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 new file mode 100644 index 000000000000..e0e0da2e9e40 --- /dev/null +++ b/packages/google-cloud-source-context/mypy.ini @@ -0,0 +1,15 @@ +[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 3328e26ef35e..6488b4a11907 100644 --- a/packages/google-cloud-source-context/noxfile.py +++ b/packages/google-cloud-source-context/noxfile.py @@ -46,17 +46,6 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), -) - if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -118,7 +107,6 @@ def mypy(session): session.install(".") session.run( "mypy", - f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", diff --git a/packages/google-geo-type/mypy.ini b/packages/google-geo-type/mypy.ini new file mode 100644 index 000000000000..e0e0da2e9e40 --- /dev/null +++ b/packages/google-geo-type/mypy.ini @@ -0,0 +1,15 @@ +[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 b14318c5c426..c7dd9bef9aaa 100644 --- a/packages/google-geo-type/noxfile.py +++ b/packages/google-geo-type/noxfile.py @@ -46,17 +46,6 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), -) - if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -118,7 +107,6 @@ def mypy(session): session.install(".") session.run( "mypy", - f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--check-untyped-defs", From 2f63dcc8036dcb9b578d4f42ff2f912d9eeab498 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 30 Jun 2026 14:27:24 -0400 Subject: [PATCH 10/18] feat(handwritten): centralize mypy config for hybrid packages and add overrides --- mypy.ini | 17 ++ packages/google-cloud-bigtable/mypy.ini | 38 --- packages/google-cloud-bigtable/noxfile.py | 13 +- packages/google-cloud-datastore/mypy.ini | 23 -- packages/google-cloud-datastore/noxfile.py | 12 + .../google-cloud-error-reporting/mypy.ini | 15 - .../google-cloud-error-reporting/noxfile.py | 12 + packages/google-cloud-firestore/mypy.ini | 15 - packages/google-cloud-firestore/noxfile.py | 13 +- packages/google-cloud-logging/mypy.ini | 15 - packages/google-cloud-logging/noxfile.py | 11 + packages/google-cloud-pubsub/mypy.ini | 15 - packages/google-cloud-pubsub/noxfile.py | 13 +- packages/google-cloud-spanner/mypy.ini | 15 - packages/google-cloud-spanner/noxfile.py | 12 + packages/google-cloud-storage/mypy.ini | 15 - packages/google-cloud-storage/noxfile.py | 11 + scratch/analyze_libraries.py | 93 ++++++ scratch/dump_noxfile_replacements.py | 29 ++ scratch/generate_analysis_csv.py | 95 ++++++ scratch/library_analysis.csv | 282 ++++++++++++++++++ 21 files changed, 610 insertions(+), 154 deletions(-) delete mode 100644 packages/google-cloud-bigtable/mypy.ini delete mode 100644 packages/google-cloud-datastore/mypy.ini delete mode 100644 packages/google-cloud-error-reporting/mypy.ini delete mode 100644 packages/google-cloud-firestore/mypy.ini delete mode 100644 packages/google-cloud-logging/mypy.ini delete mode 100644 packages/google-cloud-pubsub/mypy.ini delete mode 100644 packages/google-cloud-spanner/mypy.ini delete mode 100644 packages/google-cloud-storage/mypy.ini create mode 100644 scratch/analyze_libraries.py create mode 100644 scratch/dump_noxfile_replacements.py create mode 100644 scratch/generate_analysis_csv.py create mode 100644 scratch/library_analysis.csv diff --git a/mypy.ini b/mypy.ini index 5cf75c85794f..4a9a43ab38e3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -100,3 +100,20 @@ ignore_errors = False # --- bigframes --- [mypy-bigframes_vendored.*] ignore_errors = True + +# --- google-cloud-datastore --- +[mypy-google.cloud.datastore.*] +ignore_missing_imports = True + +[mypy-google.cloud.datastore._app_engine_key_pb2] +ignore_errors = True + +[mypy-google.cloud.datastore_v1.services.datastore.async_client] +ignore_errors = True + +[mypy-google.cloud.datastore_v1.services.datastore.client] +ignore_errors = True + +# --- google-cloud-firestore --- +[mypy-google.cloud.firestore.*] +check_untyped_defs = True diff --git a/packages/google-cloud-bigtable/mypy.ini b/packages/google-cloud-bigtable/mypy.ini deleted file mode 100644 index 701b7587ce6f..000000000000 --- a/packages/google-cloud-bigtable/mypy.ini +++ /dev/null @@ -1,38 +0,0 @@ -[mypy] -python_version = 3.13 -namespace_packages = True -check_untyped_defs = True -warn_unreachable = True -disallow_any_generics = True -exclude = tests/unit/gapic/ - -[mypy-grpc.*] -ignore_missing_imports = True - -[mypy-google.auth.*] -ignore_missing_imports = True - -[mypy-google.iam.*] -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 - -[mypy-google.cloud.*] -ignore_errors = True - -# only verify data client -[mypy-google.cloud.bigtable.data.*] -ignore_errors = False diff --git a/packages/google-cloud-bigtable/noxfile.py b/packages/google-cloud-bigtable/noxfile.py index e6ef8c1e9911..dbc582ebaab1 100644 --- a/packages/google-cloud-bigtable/noxfile.py +++ b/packages/google-cloud-bigtable/noxfile.py @@ -66,6 +66,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"), +) + # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ @@ -175,7 +186,7 @@ def mypy(session): "types-requests", ) session.install("google-cloud-testutils") - session.run("mypy", "-p", "google.cloud.bigtable.data") + session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "-p", "google.cloud.bigtable.data") @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/google-cloud-datastore/mypy.ini b/packages/google-cloud-datastore/mypy.ini deleted file mode 100644 index 2d553926db9d..000000000000 --- a/packages/google-cloud-datastore/mypy.ini +++ /dev/null @@ -1,23 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True -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 - -[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 - -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2410): -# Remove once this generator bug is fixed -[mypy-google.cloud.datastore_v1.services.datastore.client] -ignore_errors = True diff --git a/packages/google-cloud-datastore/noxfile.py b/packages/google-cloud-datastore/noxfile.py index af42d740478e..d803e9759965 100644 --- a/packages/google-cloud-datastore/noxfile.py +++ b/packages/google-cloud-datastore/noxfile.py @@ -46,6 +46,17 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), +) + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +118,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", # TODO(https://github.com/googleapis/google-cloud-python/issues/16083) diff --git a/packages/google-cloud-error-reporting/mypy.ini b/packages/google-cloud-error-reporting/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-error-reporting/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-error-reporting/noxfile.py b/packages/google-cloud-error-reporting/noxfile.py index e13108291d94..9c99c1dbc424 100644 --- a/packages/google-cloud-error-reporting/noxfile.py +++ b/packages/google-cloud-error-reporting/noxfile.py @@ -46,6 +46,17 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), +) + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -107,6 +118,7 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", # TODO(https://github.com/googleapis/google-cloud-python/issues/16083) diff --git a/packages/google-cloud-firestore/mypy.ini b/packages/google-cloud-firestore/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-firestore/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-firestore/noxfile.py b/packages/google-cloud-firestore/noxfile.py index 4df37240719c..56ef7dcac0d5 100644 --- a/packages/google-cloud-firestore/noxfile.py +++ b/packages/google-cloud-firestore/noxfile.py @@ -46,6 +46,17 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), +) + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( @@ -166,9 +177,9 @@ def mypy(session): session.install(".") session.run( "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", - "--check-untyped-defs", *session.posargs, ) diff --git a/packages/google-cloud-logging/mypy.ini b/packages/google-cloud-logging/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-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-logging/noxfile.py b/packages/google-cloud-logging/noxfile.py index f243539c2d21..2f8d10e8342f 100644 --- a/packages/google-cloud-logging/noxfile.py +++ b/packages/google-cloud-logging/noxfile.py @@ -46,6 +46,17 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), +) + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( diff --git a/packages/google-cloud-pubsub/mypy.ini b/packages/google-cloud-pubsub/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-pubsub/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-pubsub/noxfile.py b/packages/google-cloud-pubsub/noxfile.py index fb01bc8d1105..f6f697a38073 100644 --- a/packages/google-cloud-pubsub/noxfile.py +++ b/packages/google-cloud-pubsub/noxfile.py @@ -86,6 +86,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", @@ -133,7 +144,7 @@ def mypy(session): # mypy checks yet. # https://github.com/googleapis/gapic-generator-python/issues/1092 # TODO: Re-enable mypy checks once we merge, since incremental checks are failing due to protobuf upgrade - # session.run("mypy", "-p", "google.cloud", "--exclude", "google/pubsub_v1/") + # session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "-p", "google.cloud", "--exclude", "google/pubsub_v1/") @nox.session(python=DEFAULT_PYTHON_VERSION) 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-storage/mypy.ini b/packages/google-cloud-storage/mypy.ini deleted file mode 100644 index e0e0da2e9e40..000000000000 --- a/packages/google-cloud-storage/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-storage/noxfile.py b/packages/google-cloud-storage/noxfile.py index 6e8d41c60b3d..18ef45502ca8 100644 --- a/packages/google-cloud-storage/noxfile.py +++ b/packages/google-cloud-storage/noxfile.py @@ -46,6 +46,17 @@ PREVIEW_PYTHON_VERSION = "3.14" 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"), +) + if (CURRENT_DIRECTORY / "testing").exists(): LOWER_BOUND_CONSTRAINTS_FILE = ( diff --git a/scratch/analyze_libraries.py b/scratch/analyze_libraries.py new file mode 100644 index 000000000000..3a83292235eb --- /dev/null +++ b/scratch/analyze_libraries.py @@ -0,0 +1,93 @@ +import yaml +import os +import glob +import re + +# Paths +LIBRARIAN_YAML = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/librarian.yaml" +POST_PROCESSING_DIR = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/.librarian/generator-input/client-post-processing" + +# Load librarian.yaml +with open(LIBRARIAN_YAML, 'r') as f: + librarian_data = yaml.safe_load(f) + +libraries = librarian_data.get('libraries', []) + +# Find all post-processing files +post_processing_files = glob.glob(os.path.join(POST_PROCESSING_DIR, "*.yaml")) + +# Analyze post-processing files for mypy/noxfile replacements +mypy_replacements = {} +noxfile_mypy_replacements = {} + +for file_path in post_processing_files: + with open(file_path, 'r') as f: + try: + data = yaml.safe_load(f) + except yaml.YAMLError as e: + print(f"Error parsing {file_path}: {e}") + continue + + if not data or 'replacements' not in data: + continue + + for rep in data['replacements']: + paths = rep.get('paths', []) + for p in paths: + # Extract package name from path: packages//... + match = re.match(r"packages/([^/]+)/", p) + if match: + package_name = match.group(1) + if "mypy.ini" in p: + if package_name not in mypy_replacements: + mypy_replacements[package_name] = [] + mypy_replacements[package_name].append(file_path) + elif "noxfile.py" in p: + # Check if replacement is about mypy + before = rep.get('before', '') + after = rep.get('after', '') + if 'mypy' in before or 'mypy' in after: + if package_name not in noxfile_mypy_replacements: + noxfile_mypy_replacements[package_name] = [] + noxfile_mypy_replacements[package_name].append(file_path) + +# Prepare summary +summary = [] + +for lib in libraries: + name = lib.get('name') + apis = lib.get('apis', []) + apis_populated = len(apis) > 0 + + is_handwritten = not apis_populated + is_hybrid = False + + reasons = [] + + if is_handwritten: + reasons.append("No 'apis' key in librarian.yaml") + else: + # Check if hybrid + if name in mypy_replacements: + is_hybrid = True + reasons.append(f"mypy.ini replaced in {', '.join([os.path.basename(f) for f in mypy_replacements[name]])}") + if name in noxfile_mypy_replacements: + is_hybrid = True + reasons.append(f"noxfile.py mypy session replaced in {', '.join([os.path.basename(f) for f in noxfile_mypy_replacements[name]])}") + + lib_type = "Handwritten" if is_handwritten else ("Hybrid" if is_hybrid else "GAPIC_AUTO") + + if lib_type in ["Handwritten", "Hybrid"]: + summary.append({ + 'name': name, + 'apis_populated': apis_populated, + 'type': lib_type, + 'reasons': '; '.join(reasons) + }) + +# Output as Markdown Table +print("| Package Name | APIs Populated | Type | Reasons |") +print("| --- | --- | --- | --- |") +for item in summary: + print(f"| {item['name']} | {item['apis_populated']} | {item['type']} | {item['reasons']} |") + diff --git a/scratch/dump_noxfile_replacements.py b/scratch/dump_noxfile_replacements.py new file mode 100644 index 000000000000..7717586b4a80 --- /dev/null +++ b/scratch/dump_noxfile_replacements.py @@ -0,0 +1,29 @@ +import yaml +import os +import glob +import re + +POST_PROCESSING_DIR = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/.librarian/generator-input/client-post-processing" + +post_processing_files = glob.glob(os.path.join(POST_PROCESSING_DIR, "*.yaml")) + +print("=== Noxfile Replacements ===") +for file_path in post_processing_files: + with open(file_path, 'r') as f: + try: + data = yaml.safe_load(f) + except yaml.YAMLError as e: + continue + + if not data or 'replacements' not in data: + continue + + for rep in data['replacements']: + paths = rep.get('paths', []) + for p in paths: + if "noxfile.py" in p: + print(f"File: {os.path.basename(file_path)}") + print(f"Path: {p}") + print(f"Before: {rep.get('before', '')}") + print(f"After: {rep.get('after', '')}") + print("-" * 20) diff --git a/scratch/generate_analysis_csv.py b/scratch/generate_analysis_csv.py new file mode 100644 index 000000000000..18fda212b346 --- /dev/null +++ b/scratch/generate_analysis_csv.py @@ -0,0 +1,95 @@ +import yaml +import os +import glob +import re +import csv + +# Paths +LIBRARIAN_YAML = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/librarian.yaml" +POST_PROCESSING_DIR = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/.librarian/generator-input/client-post-processing" +OUTPUT_CSV = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/scratch/library_analysis.csv" + +# Load librarian.yaml +with open(LIBRARIAN_YAML, 'r') as f: + librarian_data = yaml.safe_load(f) + +libraries = librarian_data.get('libraries', []) + +# Find all post-processing files +post_processing_files = glob.glob(os.path.join(POST_PROCESSING_DIR, "*.yaml")) + +# Analyze post-processing files for mypy/noxfile replacements +mypy_replacements = {} +noxfile_mypy_replacements = {} + +for file_path in post_processing_files: + with open(file_path, 'r') as f: + try: + data = yaml.safe_load(f) + except yaml.YAMLError as e: + continue + + if not data or 'replacements' not in data: + continue + + for rep in data['replacements']: + paths = rep.get('paths', []) + for p in paths: + match = re.match(r"packages/([^/]+)/", p) + if match: + package_name = match.group(1) + if "mypy.ini" in p: + if package_name not in mypy_replacements: + mypy_replacements[package_name] = [] + mypy_replacements[package_name].append(file_path) + elif "noxfile.py" in p: + before = rep.get('before', '') + after = rep.get('after', '') + # Broader check for mypy relevance + if 'mypy' in before or 'mypy' in after or 'check-untyped-defs' in before or 'check-untyped-defs' in after: + if package_name not in noxfile_mypy_replacements: + noxfile_mypy_replacements[package_name] = [] + noxfile_mypy_replacements[package_name].append(file_path) + +# Prepare summary +summary = [] + +for lib in libraries: + name = lib.get('name') + apis = lib.get('apis', []) + apis_populated = len(apis) > 0 + + is_handwritten = not apis_populated + is_hybrid = False + + if not is_handwritten: + if name in mypy_replacements or name in noxfile_mypy_replacements: + is_hybrid = True + + lib_type = "Handwritten" if is_handwritten else ("Hybrid" if is_hybrid else "GAPIC_AUTO") + + summary.append({ + 'Package Name': name, + 'APIs Populated': apis_populated, + 'Detected Type': lib_type, + 'Has Mypy Post-Processing': is_hybrid + }) + +# Add google-cloud-spanner-dbapi-driver manually as it's not in librarian.yaml but in packages/ +summary.append({ + 'Package Name': 'google-cloud-spanner-dbapi-driver', + 'APIs Populated': False, + 'Detected Type': 'Handwritten', + 'Has Mypy Post-Processing': False +}) + +# Write to CSV +with open(OUTPUT_CSV, 'w', newline='') as csvfile: + fieldnames = ['Package Name', 'APIs Populated', 'Detected Type', 'Has Mypy Post-Processing'] + writer = csv.DictWriter(csvfile, fieldnames=fieldnames) + + writer.writeheader() + for row in summary: + writer.writerow(row) + +print(f"Analysis saved to {OUTPUT_CSV}") diff --git a/scratch/library_analysis.csv b/scratch/library_analysis.csv new file mode 100644 index 000000000000..d2bd6738d867 --- /dev/null +++ b/scratch/library_analysis.csv @@ -0,0 +1,282 @@ +Package Name,APIs Populated,Detected Type,Has Mypy Post-Processing +bigframes,False,Handwritten,False +bigquery-magics,False,Handwritten,False +db-dtypes,False,Handwritten,False +django-google-spanner,False,Handwritten,False +gapic-generator,False,Handwritten,False +gcp-sphinx-docfx-yaml,False,Handwritten,False +google-ads-admanager,True,GAPIC_AUTO,False +google-ads-datamanager,True,GAPIC_AUTO,False +google-ads-marketingplatform-admin,True,GAPIC_AUTO,False +google-ai-generativelanguage,True,GAPIC_AUTO,False +google-analytics-admin,True,GAPIC_AUTO,False +google-analytics-data,True,GAPIC_AUTO,False +google-api-core,False,Handwritten,False +google-apps-card,True,GAPIC_AUTO,False +google-apps-chat,True,GAPIC_AUTO,False +google-apps-events-subscriptions,True,GAPIC_AUTO,False +google-apps-meet,True,GAPIC_AUTO,False +google-apps-script-type,True,GAPIC_AUTO,False +google-area120-tables,True,GAPIC_AUTO,False +google-auth,False,Handwritten,False +google-auth-httplib2,False,Handwritten,False +google-auth-oauthlib,False,Handwritten,False +google-backstory,True,GAPIC_AUTO,False +google-cloud-access-approval,True,GAPIC_AUTO,False +google-cloud-access-context-manager,True,GAPIC_AUTO,False +google-cloud-advisorynotifications,True,GAPIC_AUTO,False +google-cloud-agentidentitycredentials,True,GAPIC_AUTO,False +google-cloud-alloydb,True,GAPIC_AUTO,False +google-cloud-alloydb-connectors,True,GAPIC_AUTO,False +google-cloud-api-gateway,True,GAPIC_AUTO,False +google-cloud-api-keys,True,GAPIC_AUTO,False +google-cloud-apigee-connect,True,GAPIC_AUTO,False +google-cloud-apigee-registry,True,GAPIC_AUTO,False +google-cloud-apihub,True,GAPIC_AUTO,False +google-cloud-apiregistry,True,GAPIC_AUTO,False +google-cloud-appengine-admin,True,GAPIC_AUTO,False +google-cloud-appengine-logging,True,GAPIC_AUTO,False +google-cloud-apphub,True,GAPIC_AUTO,False +google-cloud-appoptimize,True,GAPIC_AUTO,False +google-cloud-artifact-registry,True,GAPIC_AUTO,False +google-cloud-asset,True,GAPIC_AUTO,False +google-cloud-assured-workloads,True,GAPIC_AUTO,False +google-cloud-audit-log,True,GAPIC_AUTO,False +google-cloud-auditmanager,True,GAPIC_AUTO,False +google-cloud-automl,True,GAPIC_AUTO,False +google-cloud-backupdr,True,GAPIC_AUTO,False +google-cloud-bare-metal-solution,True,GAPIC_AUTO,False +google-cloud-batch,True,GAPIC_AUTO,False +google-cloud-beyondcorp-appconnections,True,GAPIC_AUTO,False +google-cloud-beyondcorp-appconnectors,True,GAPIC_AUTO,False +google-cloud-beyondcorp-appgateways,True,GAPIC_AUTO,False +google-cloud-beyondcorp-clientconnectorservices,True,GAPIC_AUTO,False +google-cloud-beyondcorp-clientgateways,True,GAPIC_AUTO,False +google-cloud-biglake,True,GAPIC_AUTO,False +google-cloud-biglake-hive,True,GAPIC_AUTO,False +google-cloud-bigquery,False,Handwritten,False +google-cloud-bigquery-analyticshub,True,GAPIC_AUTO,False +google-cloud-bigquery-biglake,True,GAPIC_AUTO,False +google-cloud-bigquery-connection,True,GAPIC_AUTO,False +google-cloud-bigquery-data-exchange,True,GAPIC_AUTO,False +google-cloud-bigquery-datapolicies,True,GAPIC_AUTO,False +google-cloud-bigquery-datatransfer,True,GAPIC_AUTO,False +google-cloud-bigquery-logging,True,GAPIC_AUTO,False +google-cloud-bigquery-migration,True,GAPIC_AUTO,False +google-cloud-bigquery-reservation,True,GAPIC_AUTO,False +google-cloud-bigquery-storage,True,Hybrid,True +google-cloud-bigtable,True,Hybrid,True +google-cloud-billing,True,GAPIC_AUTO,False +google-cloud-billing-budgets,True,GAPIC_AUTO,False +google-cloud-binary-authorization,True,GAPIC_AUTO,False +google-cloud-build,True,GAPIC_AUTO,False +google-cloud-capacityplanner,True,GAPIC_AUTO,False +google-cloud-certificate-manager,True,GAPIC_AUTO,False +google-cloud-ces,True,GAPIC_AUTO,False +google-cloud-channel,True,GAPIC_AUTO,False +google-cloud-chronicle,True,GAPIC_AUTO,False +google-cloud-cloudcontrolspartner,True,GAPIC_AUTO,False +google-cloud-cloudsecuritycompliance,True,GAPIC_AUTO,False +google-cloud-commerce-consumer-procurement,True,GAPIC_AUTO,False +google-cloud-common,True,GAPIC_AUTO,False +google-cloud-compute,True,GAPIC_AUTO,False +google-cloud-compute-v1beta,True,GAPIC_AUTO,False +google-cloud-confidentialcomputing,True,GAPIC_AUTO,False +google-cloud-config,True,GAPIC_AUTO,False +google-cloud-configdelivery,True,GAPIC_AUTO,False +google-cloud-contact-center-insights,True,GAPIC_AUTO,False +google-cloud-container,True,GAPIC_AUTO,False +google-cloud-containeranalysis,True,GAPIC_AUTO,False +google-cloud-contentwarehouse,True,GAPIC_AUTO,False +google-cloud-core,False,Handwritten,False +google-cloud-data-fusion,True,GAPIC_AUTO,False +google-cloud-data-qna,True,GAPIC_AUTO,False +google-cloud-databasecenter,True,GAPIC_AUTO,False +google-cloud-datacatalog,True,GAPIC_AUTO,False +google-cloud-datacatalog-lineage,True,GAPIC_AUTO,False +google-cloud-datacatalog-lineage-configmanagement,True,GAPIC_AUTO,False +google-cloud-dataflow-client,True,GAPIC_AUTO,False +google-cloud-dataform,True,GAPIC_AUTO,False +google-cloud-datalabeling,True,GAPIC_AUTO,False +google-cloud-dataplex,True,GAPIC_AUTO,False +google-cloud-dataproc,True,GAPIC_AUTO,False +google-cloud-dataproc-metastore,True,GAPIC_AUTO,False +google-cloud-datastore,True,Hybrid,True +google-cloud-datastream,True,GAPIC_AUTO,False +google-cloud-deploy,True,GAPIC_AUTO,False +google-cloud-developerconnect,True,GAPIC_AUTO,False +google-cloud-devicestreaming,True,GAPIC_AUTO,False +google-cloud-dialogflow,True,GAPIC_AUTO,False +google-cloud-dialogflow-cx,True,GAPIC_AUTO,False +google-cloud-discoveryengine,True,GAPIC_AUTO,False +google-cloud-dlp,True,GAPIC_AUTO,False +google-cloud-dms,True,GAPIC_AUTO,False +google-cloud-dns,False,Handwritten,False +google-cloud-documentai,True,GAPIC_AUTO,False +google-cloud-documentai-toolbox,False,Handwritten,False +google-cloud-domains,True,GAPIC_AUTO,False +google-cloud-edgecontainer,True,GAPIC_AUTO,False +google-cloud-edgenetwork,True,GAPIC_AUTO,False +google-cloud-enterpriseknowledgegraph,True,GAPIC_AUTO,False +google-cloud-error-reporting,True,Hybrid,True +google-cloud-essential-contacts,True,GAPIC_AUTO,False +google-cloud-eventarc,True,GAPIC_AUTO,False +google-cloud-eventarc-publishing,True,GAPIC_AUTO,False +google-cloud-filestore,True,GAPIC_AUTO,False +google-cloud-financialservices,True,GAPIC_AUTO,False +google-cloud-firestore,True,Hybrid,True +google-cloud-functions,True,GAPIC_AUTO,False +google-cloud-gdchardwaremanagement,True,GAPIC_AUTO,False +google-cloud-geminidataanalytics,True,GAPIC_AUTO,False +google-cloud-gke-backup,True,GAPIC_AUTO,False +google-cloud-gke-connect-gateway,True,GAPIC_AUTO,False +google-cloud-gke-hub,True,GAPIC_AUTO,False +google-cloud-gke-multicloud,True,GAPIC_AUTO,False +google-cloud-gkerecommender,True,GAPIC_AUTO,False +google-cloud-gsuiteaddons,True,GAPIC_AUTO,False +google-cloud-hypercomputecluster,True,GAPIC_AUTO,False +google-cloud-iam,True,GAPIC_AUTO,False +google-cloud-iam-logging,True,GAPIC_AUTO,False +google-cloud-iamconnectorcredentials,True,GAPIC_AUTO,False +google-cloud-iap,True,GAPIC_AUTO,False +google-cloud-ids,True,GAPIC_AUTO,False +google-cloud-kms,True,GAPIC_AUTO,False +google-cloud-kms-inventory,True,GAPIC_AUTO,False +google-cloud-language,True,GAPIC_AUTO,False +google-cloud-licensemanager,True,GAPIC_AUTO,False +google-cloud-life-sciences,True,GAPIC_AUTO,False +google-cloud-locationfinder,True,GAPIC_AUTO,False +google-cloud-logging,True,Hybrid,True +google-cloud-lustre,True,GAPIC_AUTO,False +google-cloud-maintenance-api,True,GAPIC_AUTO,False +google-cloud-managed-identities,True,GAPIC_AUTO,False +google-cloud-managedkafka,True,GAPIC_AUTO,False +google-cloud-managedkafka-schemaregistry,True,GAPIC_AUTO,False +google-cloud-media-translation,True,GAPIC_AUTO,False +google-cloud-memcache,True,GAPIC_AUTO,False +google-cloud-memorystore,True,GAPIC_AUTO,False +google-cloud-migrationcenter,True,GAPIC_AUTO,False +google-cloud-modelarmor,True,GAPIC_AUTO,False +google-cloud-monitoring,True,Hybrid,True +google-cloud-monitoring-dashboards,True,Hybrid,True +google-cloud-monitoring-metrics-scopes,True,GAPIC_AUTO,False +google-cloud-ndb,False,Handwritten,False +google-cloud-netapp,True,GAPIC_AUTO,False +google-cloud-network-connectivity,True,GAPIC_AUTO,False +google-cloud-network-management,True,GAPIC_AUTO,False +google-cloud-network-security,True,GAPIC_AUTO,False +google-cloud-network-services,True,GAPIC_AUTO,False +google-cloud-notebooks,True,GAPIC_AUTO,False +google-cloud-optimization,True,GAPIC_AUTO,False +google-cloud-oracledatabase,True,GAPIC_AUTO,False +google-cloud-orchestration-airflow,True,GAPIC_AUTO,False +google-cloud-org-policy,True,GAPIC_AUTO,False +google-cloud-os-config,True,GAPIC_AUTO,False +google-cloud-os-login,True,GAPIC_AUTO,False +google-cloud-parallelstore,True,GAPIC_AUTO,False +google-cloud-parametermanager,True,GAPIC_AUTO,False +google-cloud-phishing-protection,True,GAPIC_AUTO,False +google-cloud-policy-troubleshooter,True,GAPIC_AUTO,False +google-cloud-policysimulator,True,GAPIC_AUTO,False +google-cloud-policytroubleshooter-iam,True,GAPIC_AUTO,False +google-cloud-private-ca,True,GAPIC_AUTO,False +google-cloud-private-catalog,True,GAPIC_AUTO,False +google-cloud-privilegedaccessmanager,True,GAPIC_AUTO,False +google-cloud-pubsub,True,Hybrid,True +google-cloud-quotas,True,GAPIC_AUTO,False +google-cloud-rapidmigrationassessment,True,GAPIC_AUTO,False +google-cloud-recaptcha-enterprise,True,GAPIC_AUTO,False +google-cloud-recommendations-ai,True,GAPIC_AUTO,False +google-cloud-recommender,True,GAPIC_AUTO,False +google-cloud-redis,True,GAPIC_AUTO,False +google-cloud-redis-cluster,True,GAPIC_AUTO,False +google-cloud-resource-manager,True,GAPIC_AUTO,False +google-cloud-retail,True,GAPIC_AUTO,False +google-cloud-run,True,GAPIC_AUTO,False +google-cloud-runtimeconfig,False,Handwritten,False +google-cloud-saasplatform-saasservicemgmt,True,GAPIC_AUTO,False +google-cloud-scheduler,True,GAPIC_AUTO,False +google-cloud-secret-manager,True,GAPIC_AUTO,False +google-cloud-securesourcemanager,True,GAPIC_AUTO,False +google-cloud-security-publicca,True,GAPIC_AUTO,False +google-cloud-securitycenter,True,GAPIC_AUTO,False +google-cloud-securitycentermanagement,True,GAPIC_AUTO,False +google-cloud-service-control,True,GAPIC_AUTO,False +google-cloud-service-directory,True,GAPIC_AUTO,False +google-cloud-service-management,True,GAPIC_AUTO,False +google-cloud-service-usage,True,GAPIC_AUTO,False +google-cloud-servicehealth,True,GAPIC_AUTO,False +google-cloud-shell,True,GAPIC_AUTO,False +google-cloud-source-context,True,GAPIC_AUTO,False +google-cloud-spanner,True,Hybrid,True +google-cloud-speech,True,Hybrid,True +google-cloud-storage,True,Hybrid,True +google-cloud-storage-control,True,GAPIC_AUTO,False +google-cloud-storage-transfer,True,GAPIC_AUTO,False +google-cloud-storagebatchoperations,True,GAPIC_AUTO,False +google-cloud-storageinsights,True,GAPIC_AUTO,False +google-cloud-support,True,GAPIC_AUTO,False +google-cloud-talent,True,GAPIC_AUTO,False +google-cloud-tasks,True,GAPIC_AUTO,False +google-cloud-telcoautomation,True,GAPIC_AUTO,False +google-cloud-testutils,False,Handwritten,False +google-cloud-texttospeech,True,GAPIC_AUTO,False +google-cloud-tpu,True,GAPIC_AUTO,False +google-cloud-trace,True,GAPIC_AUTO,False +google-cloud-translate,True,GAPIC_AUTO,False +google-cloud-vectorsearch,True,GAPIC_AUTO,False +google-cloud-video-live-stream,True,GAPIC_AUTO,False +google-cloud-video-stitcher,True,GAPIC_AUTO,False +google-cloud-video-transcoder,True,GAPIC_AUTO,False +google-cloud-videointelligence,True,GAPIC_AUTO,False +google-cloud-vision,True,Hybrid,True +google-cloud-visionai,True,GAPIC_AUTO,False +google-cloud-vm-migration,True,GAPIC_AUTO,False +google-cloud-vmwareengine,True,GAPIC_AUTO,False +google-cloud-vpc-access,True,GAPIC_AUTO,False +google-cloud-webrisk,True,GAPIC_AUTO,False +google-cloud-websecurityscanner,True,GAPIC_AUTO,False +google-cloud-workflows,True,GAPIC_AUTO,False +google-cloud-workloadmanager,True,GAPIC_AUTO,False +google-cloud-workstations,True,GAPIC_AUTO,False +google-crc32c,False,Handwritten,False +google-developer-knowledge,True,GAPIC_AUTO,False +google-devicesandservices-health,True,GAPIC_AUTO,False +google-geo-type,True,GAPIC_AUTO,False +google-maps-addressvalidation,True,GAPIC_AUTO,False +google-maps-areainsights,True,GAPIC_AUTO,False +google-maps-fleetengine,True,GAPIC_AUTO,False +google-maps-fleetengine-delivery,True,GAPIC_AUTO,False +google-maps-geocode,True,GAPIC_AUTO,False +google-maps-mapmanagement,True,GAPIC_AUTO,False +google-maps-mapsplatformdatasets,True,GAPIC_AUTO,False +google-maps-navconnect,True,GAPIC_AUTO,False +google-maps-places,True,GAPIC_AUTO,False +google-maps-routeoptimization,True,GAPIC_AUTO,False +google-maps-routing,True,GAPIC_AUTO,False +google-maps-solar,True,GAPIC_AUTO,False +google-resumable-media,False,Handwritten,False +google-shopping-css,True,GAPIC_AUTO,False +google-shopping-merchant-accounts,True,GAPIC_AUTO,False +google-shopping-merchant-conversions,True,GAPIC_AUTO,False +google-shopping-merchant-datasources,True,GAPIC_AUTO,False +google-shopping-merchant-inventories,True,GAPIC_AUTO,False +google-shopping-merchant-issueresolution,True,GAPIC_AUTO,False +google-shopping-merchant-lfp,True,GAPIC_AUTO,False +google-shopping-merchant-notifications,True,GAPIC_AUTO,False +google-shopping-merchant-ordertracking,True,GAPIC_AUTO,False +google-shopping-merchant-products,True,GAPIC_AUTO,False +google-shopping-merchant-productstudio,True,GAPIC_AUTO,False +google-shopping-merchant-promotions,True,GAPIC_AUTO,False +google-shopping-merchant-quota,True,GAPIC_AUTO,False +google-shopping-merchant-reports,True,GAPIC_AUTO,False +google-shopping-merchant-reviews,True,GAPIC_AUTO,False +google-shopping-type,True,GAPIC_AUTO,False +googleapis-common-protos,True,GAPIC_AUTO,False +grafeas,True,GAPIC_AUTO,False +grpc-google-iam-v1,True,GAPIC_AUTO,False +pandas-gbq,False,Handwritten,False +proto-plus,False,Handwritten,False +sqlalchemy-bigquery,False,Handwritten,False +sqlalchemy-spanner,False,Handwritten,False +google-cloud-spanner-dbapi-driver,False,Handwritten,False From 5db0eda769bcd964f4a86a9a7dcb9ffc1734f1ca Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 30 Jun 2026 14:30:04 -0400 Subject: [PATCH 11/18] chore: remove scratch files from PR --- scratch/analyze_libraries.py | 93 --------- scratch/dump_noxfile_replacements.py | 29 --- scratch/generate_analysis_csv.py | 95 --------- scratch/library_analysis.csv | 282 --------------------------- 4 files changed, 499 deletions(-) delete mode 100644 scratch/analyze_libraries.py delete mode 100644 scratch/dump_noxfile_replacements.py delete mode 100644 scratch/generate_analysis_csv.py delete mode 100644 scratch/library_analysis.csv diff --git a/scratch/analyze_libraries.py b/scratch/analyze_libraries.py deleted file mode 100644 index 3a83292235eb..000000000000 --- a/scratch/analyze_libraries.py +++ /dev/null @@ -1,93 +0,0 @@ -import yaml -import os -import glob -import re - -# Paths -LIBRARIAN_YAML = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/librarian.yaml" -POST_PROCESSING_DIR = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/.librarian/generator-input/client-post-processing" - -# Load librarian.yaml -with open(LIBRARIAN_YAML, 'r') as f: - librarian_data = yaml.safe_load(f) - -libraries = librarian_data.get('libraries', []) - -# Find all post-processing files -post_processing_files = glob.glob(os.path.join(POST_PROCESSING_DIR, "*.yaml")) - -# Analyze post-processing files for mypy/noxfile replacements -mypy_replacements = {} -noxfile_mypy_replacements = {} - -for file_path in post_processing_files: - with open(file_path, 'r') as f: - try: - data = yaml.safe_load(f) - except yaml.YAMLError as e: - print(f"Error parsing {file_path}: {e}") - continue - - if not data or 'replacements' not in data: - continue - - for rep in data['replacements']: - paths = rep.get('paths', []) - for p in paths: - # Extract package name from path: packages//... - match = re.match(r"packages/([^/]+)/", p) - if match: - package_name = match.group(1) - if "mypy.ini" in p: - if package_name not in mypy_replacements: - mypy_replacements[package_name] = [] - mypy_replacements[package_name].append(file_path) - elif "noxfile.py" in p: - # Check if replacement is about mypy - before = rep.get('before', '') - after = rep.get('after', '') - if 'mypy' in before or 'mypy' in after: - if package_name not in noxfile_mypy_replacements: - noxfile_mypy_replacements[package_name] = [] - noxfile_mypy_replacements[package_name].append(file_path) - -# Prepare summary -summary = [] - -for lib in libraries: - name = lib.get('name') - apis = lib.get('apis', []) - apis_populated = len(apis) > 0 - - is_handwritten = not apis_populated - is_hybrid = False - - reasons = [] - - if is_handwritten: - reasons.append("No 'apis' key in librarian.yaml") - else: - # Check if hybrid - if name in mypy_replacements: - is_hybrid = True - reasons.append(f"mypy.ini replaced in {', '.join([os.path.basename(f) for f in mypy_replacements[name]])}") - if name in noxfile_mypy_replacements: - is_hybrid = True - reasons.append(f"noxfile.py mypy session replaced in {', '.join([os.path.basename(f) for f in noxfile_mypy_replacements[name]])}") - - lib_type = "Handwritten" if is_handwritten else ("Hybrid" if is_hybrid else "GAPIC_AUTO") - - if lib_type in ["Handwritten", "Hybrid"]: - summary.append({ - 'name': name, - 'apis_populated': apis_populated, - 'type': lib_type, - 'reasons': '; '.join(reasons) - }) - -# Output as Markdown Table -print("| Package Name | APIs Populated | Type | Reasons |") -print("| --- | --- | --- | --- |") -for item in summary: - print(f"| {item['name']} | {item['apis_populated']} | {item['type']} | {item['reasons']} |") - diff --git a/scratch/dump_noxfile_replacements.py b/scratch/dump_noxfile_replacements.py deleted file mode 100644 index 7717586b4a80..000000000000 --- a/scratch/dump_noxfile_replacements.py +++ /dev/null @@ -1,29 +0,0 @@ -import yaml -import os -import glob -import re - -POST_PROCESSING_DIR = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/.librarian/generator-input/client-post-processing" - -post_processing_files = glob.glob(os.path.join(POST_PROCESSING_DIR, "*.yaml")) - -print("=== Noxfile Replacements ===") -for file_path in post_processing_files: - with open(file_path, 'r') as f: - try: - data = yaml.safe_load(f) - except yaml.YAMLError as e: - continue - - if not data or 'replacements' not in data: - continue - - for rep in data['replacements']: - paths = rep.get('paths', []) - for p in paths: - if "noxfile.py" in p: - print(f"File: {os.path.basename(file_path)}") - print(f"Path: {p}") - print(f"Before: {rep.get('before', '')}") - print(f"After: {rep.get('after', '')}") - print("-" * 20) diff --git a/scratch/generate_analysis_csv.py b/scratch/generate_analysis_csv.py deleted file mode 100644 index 18fda212b346..000000000000 --- a/scratch/generate_analysis_csv.py +++ /dev/null @@ -1,95 +0,0 @@ -import yaml -import os -import glob -import re -import csv - -# Paths -LIBRARIAN_YAML = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/librarian.yaml" -POST_PROCESSING_DIR = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/.librarian/generator-input/client-post-processing" -OUTPUT_CSV = "/usr/local/google/home/chalmerlowe/titan-src/projects/google-cloud-python/feat-centralize-mypy/scratch/library_analysis.csv" - -# Load librarian.yaml -with open(LIBRARIAN_YAML, 'r') as f: - librarian_data = yaml.safe_load(f) - -libraries = librarian_data.get('libraries', []) - -# Find all post-processing files -post_processing_files = glob.glob(os.path.join(POST_PROCESSING_DIR, "*.yaml")) - -# Analyze post-processing files for mypy/noxfile replacements -mypy_replacements = {} -noxfile_mypy_replacements = {} - -for file_path in post_processing_files: - with open(file_path, 'r') as f: - try: - data = yaml.safe_load(f) - except yaml.YAMLError as e: - continue - - if not data or 'replacements' not in data: - continue - - for rep in data['replacements']: - paths = rep.get('paths', []) - for p in paths: - match = re.match(r"packages/([^/]+)/", p) - if match: - package_name = match.group(1) - if "mypy.ini" in p: - if package_name not in mypy_replacements: - mypy_replacements[package_name] = [] - mypy_replacements[package_name].append(file_path) - elif "noxfile.py" in p: - before = rep.get('before', '') - after = rep.get('after', '') - # Broader check for mypy relevance - if 'mypy' in before or 'mypy' in after or 'check-untyped-defs' in before or 'check-untyped-defs' in after: - if package_name not in noxfile_mypy_replacements: - noxfile_mypy_replacements[package_name] = [] - noxfile_mypy_replacements[package_name].append(file_path) - -# Prepare summary -summary = [] - -for lib in libraries: - name = lib.get('name') - apis = lib.get('apis', []) - apis_populated = len(apis) > 0 - - is_handwritten = not apis_populated - is_hybrid = False - - if not is_handwritten: - if name in mypy_replacements or name in noxfile_mypy_replacements: - is_hybrid = True - - lib_type = "Handwritten" if is_handwritten else ("Hybrid" if is_hybrid else "GAPIC_AUTO") - - summary.append({ - 'Package Name': name, - 'APIs Populated': apis_populated, - 'Detected Type': lib_type, - 'Has Mypy Post-Processing': is_hybrid - }) - -# Add google-cloud-spanner-dbapi-driver manually as it's not in librarian.yaml but in packages/ -summary.append({ - 'Package Name': 'google-cloud-spanner-dbapi-driver', - 'APIs Populated': False, - 'Detected Type': 'Handwritten', - 'Has Mypy Post-Processing': False -}) - -# Write to CSV -with open(OUTPUT_CSV, 'w', newline='') as csvfile: - fieldnames = ['Package Name', 'APIs Populated', 'Detected Type', 'Has Mypy Post-Processing'] - writer = csv.DictWriter(csvfile, fieldnames=fieldnames) - - writer.writeheader() - for row in summary: - writer.writerow(row) - -print(f"Analysis saved to {OUTPUT_CSV}") diff --git a/scratch/library_analysis.csv b/scratch/library_analysis.csv deleted file mode 100644 index d2bd6738d867..000000000000 --- a/scratch/library_analysis.csv +++ /dev/null @@ -1,282 +0,0 @@ -Package Name,APIs Populated,Detected Type,Has Mypy Post-Processing -bigframes,False,Handwritten,False -bigquery-magics,False,Handwritten,False -db-dtypes,False,Handwritten,False -django-google-spanner,False,Handwritten,False -gapic-generator,False,Handwritten,False -gcp-sphinx-docfx-yaml,False,Handwritten,False -google-ads-admanager,True,GAPIC_AUTO,False -google-ads-datamanager,True,GAPIC_AUTO,False -google-ads-marketingplatform-admin,True,GAPIC_AUTO,False -google-ai-generativelanguage,True,GAPIC_AUTO,False -google-analytics-admin,True,GAPIC_AUTO,False -google-analytics-data,True,GAPIC_AUTO,False -google-api-core,False,Handwritten,False -google-apps-card,True,GAPIC_AUTO,False -google-apps-chat,True,GAPIC_AUTO,False -google-apps-events-subscriptions,True,GAPIC_AUTO,False -google-apps-meet,True,GAPIC_AUTO,False -google-apps-script-type,True,GAPIC_AUTO,False -google-area120-tables,True,GAPIC_AUTO,False -google-auth,False,Handwritten,False -google-auth-httplib2,False,Handwritten,False -google-auth-oauthlib,False,Handwritten,False -google-backstory,True,GAPIC_AUTO,False -google-cloud-access-approval,True,GAPIC_AUTO,False -google-cloud-access-context-manager,True,GAPIC_AUTO,False -google-cloud-advisorynotifications,True,GAPIC_AUTO,False -google-cloud-agentidentitycredentials,True,GAPIC_AUTO,False -google-cloud-alloydb,True,GAPIC_AUTO,False -google-cloud-alloydb-connectors,True,GAPIC_AUTO,False -google-cloud-api-gateway,True,GAPIC_AUTO,False -google-cloud-api-keys,True,GAPIC_AUTO,False -google-cloud-apigee-connect,True,GAPIC_AUTO,False -google-cloud-apigee-registry,True,GAPIC_AUTO,False -google-cloud-apihub,True,GAPIC_AUTO,False -google-cloud-apiregistry,True,GAPIC_AUTO,False -google-cloud-appengine-admin,True,GAPIC_AUTO,False -google-cloud-appengine-logging,True,GAPIC_AUTO,False -google-cloud-apphub,True,GAPIC_AUTO,False -google-cloud-appoptimize,True,GAPIC_AUTO,False -google-cloud-artifact-registry,True,GAPIC_AUTO,False -google-cloud-asset,True,GAPIC_AUTO,False -google-cloud-assured-workloads,True,GAPIC_AUTO,False -google-cloud-audit-log,True,GAPIC_AUTO,False -google-cloud-auditmanager,True,GAPIC_AUTO,False -google-cloud-automl,True,GAPIC_AUTO,False -google-cloud-backupdr,True,GAPIC_AUTO,False -google-cloud-bare-metal-solution,True,GAPIC_AUTO,False -google-cloud-batch,True,GAPIC_AUTO,False -google-cloud-beyondcorp-appconnections,True,GAPIC_AUTO,False -google-cloud-beyondcorp-appconnectors,True,GAPIC_AUTO,False -google-cloud-beyondcorp-appgateways,True,GAPIC_AUTO,False -google-cloud-beyondcorp-clientconnectorservices,True,GAPIC_AUTO,False -google-cloud-beyondcorp-clientgateways,True,GAPIC_AUTO,False -google-cloud-biglake,True,GAPIC_AUTO,False -google-cloud-biglake-hive,True,GAPIC_AUTO,False -google-cloud-bigquery,False,Handwritten,False -google-cloud-bigquery-analyticshub,True,GAPIC_AUTO,False -google-cloud-bigquery-biglake,True,GAPIC_AUTO,False -google-cloud-bigquery-connection,True,GAPIC_AUTO,False -google-cloud-bigquery-data-exchange,True,GAPIC_AUTO,False -google-cloud-bigquery-datapolicies,True,GAPIC_AUTO,False -google-cloud-bigquery-datatransfer,True,GAPIC_AUTO,False -google-cloud-bigquery-logging,True,GAPIC_AUTO,False -google-cloud-bigquery-migration,True,GAPIC_AUTO,False -google-cloud-bigquery-reservation,True,GAPIC_AUTO,False -google-cloud-bigquery-storage,True,Hybrid,True -google-cloud-bigtable,True,Hybrid,True -google-cloud-billing,True,GAPIC_AUTO,False -google-cloud-billing-budgets,True,GAPIC_AUTO,False -google-cloud-binary-authorization,True,GAPIC_AUTO,False -google-cloud-build,True,GAPIC_AUTO,False -google-cloud-capacityplanner,True,GAPIC_AUTO,False -google-cloud-certificate-manager,True,GAPIC_AUTO,False -google-cloud-ces,True,GAPIC_AUTO,False -google-cloud-channel,True,GAPIC_AUTO,False -google-cloud-chronicle,True,GAPIC_AUTO,False -google-cloud-cloudcontrolspartner,True,GAPIC_AUTO,False -google-cloud-cloudsecuritycompliance,True,GAPIC_AUTO,False -google-cloud-commerce-consumer-procurement,True,GAPIC_AUTO,False -google-cloud-common,True,GAPIC_AUTO,False -google-cloud-compute,True,GAPIC_AUTO,False -google-cloud-compute-v1beta,True,GAPIC_AUTO,False -google-cloud-confidentialcomputing,True,GAPIC_AUTO,False -google-cloud-config,True,GAPIC_AUTO,False -google-cloud-configdelivery,True,GAPIC_AUTO,False -google-cloud-contact-center-insights,True,GAPIC_AUTO,False -google-cloud-container,True,GAPIC_AUTO,False -google-cloud-containeranalysis,True,GAPIC_AUTO,False -google-cloud-contentwarehouse,True,GAPIC_AUTO,False -google-cloud-core,False,Handwritten,False -google-cloud-data-fusion,True,GAPIC_AUTO,False -google-cloud-data-qna,True,GAPIC_AUTO,False -google-cloud-databasecenter,True,GAPIC_AUTO,False -google-cloud-datacatalog,True,GAPIC_AUTO,False -google-cloud-datacatalog-lineage,True,GAPIC_AUTO,False -google-cloud-datacatalog-lineage-configmanagement,True,GAPIC_AUTO,False -google-cloud-dataflow-client,True,GAPIC_AUTO,False -google-cloud-dataform,True,GAPIC_AUTO,False -google-cloud-datalabeling,True,GAPIC_AUTO,False -google-cloud-dataplex,True,GAPIC_AUTO,False -google-cloud-dataproc,True,GAPIC_AUTO,False -google-cloud-dataproc-metastore,True,GAPIC_AUTO,False -google-cloud-datastore,True,Hybrid,True -google-cloud-datastream,True,GAPIC_AUTO,False -google-cloud-deploy,True,GAPIC_AUTO,False -google-cloud-developerconnect,True,GAPIC_AUTO,False -google-cloud-devicestreaming,True,GAPIC_AUTO,False -google-cloud-dialogflow,True,GAPIC_AUTO,False -google-cloud-dialogflow-cx,True,GAPIC_AUTO,False -google-cloud-discoveryengine,True,GAPIC_AUTO,False -google-cloud-dlp,True,GAPIC_AUTO,False -google-cloud-dms,True,GAPIC_AUTO,False -google-cloud-dns,False,Handwritten,False -google-cloud-documentai,True,GAPIC_AUTO,False -google-cloud-documentai-toolbox,False,Handwritten,False -google-cloud-domains,True,GAPIC_AUTO,False -google-cloud-edgecontainer,True,GAPIC_AUTO,False -google-cloud-edgenetwork,True,GAPIC_AUTO,False -google-cloud-enterpriseknowledgegraph,True,GAPIC_AUTO,False -google-cloud-error-reporting,True,Hybrid,True -google-cloud-essential-contacts,True,GAPIC_AUTO,False -google-cloud-eventarc,True,GAPIC_AUTO,False -google-cloud-eventarc-publishing,True,GAPIC_AUTO,False -google-cloud-filestore,True,GAPIC_AUTO,False -google-cloud-financialservices,True,GAPIC_AUTO,False -google-cloud-firestore,True,Hybrid,True -google-cloud-functions,True,GAPIC_AUTO,False -google-cloud-gdchardwaremanagement,True,GAPIC_AUTO,False -google-cloud-geminidataanalytics,True,GAPIC_AUTO,False -google-cloud-gke-backup,True,GAPIC_AUTO,False -google-cloud-gke-connect-gateway,True,GAPIC_AUTO,False -google-cloud-gke-hub,True,GAPIC_AUTO,False -google-cloud-gke-multicloud,True,GAPIC_AUTO,False -google-cloud-gkerecommender,True,GAPIC_AUTO,False -google-cloud-gsuiteaddons,True,GAPIC_AUTO,False -google-cloud-hypercomputecluster,True,GAPIC_AUTO,False -google-cloud-iam,True,GAPIC_AUTO,False -google-cloud-iam-logging,True,GAPIC_AUTO,False -google-cloud-iamconnectorcredentials,True,GAPIC_AUTO,False -google-cloud-iap,True,GAPIC_AUTO,False -google-cloud-ids,True,GAPIC_AUTO,False -google-cloud-kms,True,GAPIC_AUTO,False -google-cloud-kms-inventory,True,GAPIC_AUTO,False -google-cloud-language,True,GAPIC_AUTO,False -google-cloud-licensemanager,True,GAPIC_AUTO,False -google-cloud-life-sciences,True,GAPIC_AUTO,False -google-cloud-locationfinder,True,GAPIC_AUTO,False -google-cloud-logging,True,Hybrid,True -google-cloud-lustre,True,GAPIC_AUTO,False -google-cloud-maintenance-api,True,GAPIC_AUTO,False -google-cloud-managed-identities,True,GAPIC_AUTO,False -google-cloud-managedkafka,True,GAPIC_AUTO,False -google-cloud-managedkafka-schemaregistry,True,GAPIC_AUTO,False -google-cloud-media-translation,True,GAPIC_AUTO,False -google-cloud-memcache,True,GAPIC_AUTO,False -google-cloud-memorystore,True,GAPIC_AUTO,False -google-cloud-migrationcenter,True,GAPIC_AUTO,False -google-cloud-modelarmor,True,GAPIC_AUTO,False -google-cloud-monitoring,True,Hybrid,True -google-cloud-monitoring-dashboards,True,Hybrid,True -google-cloud-monitoring-metrics-scopes,True,GAPIC_AUTO,False -google-cloud-ndb,False,Handwritten,False -google-cloud-netapp,True,GAPIC_AUTO,False -google-cloud-network-connectivity,True,GAPIC_AUTO,False -google-cloud-network-management,True,GAPIC_AUTO,False -google-cloud-network-security,True,GAPIC_AUTO,False -google-cloud-network-services,True,GAPIC_AUTO,False -google-cloud-notebooks,True,GAPIC_AUTO,False -google-cloud-optimization,True,GAPIC_AUTO,False -google-cloud-oracledatabase,True,GAPIC_AUTO,False -google-cloud-orchestration-airflow,True,GAPIC_AUTO,False -google-cloud-org-policy,True,GAPIC_AUTO,False -google-cloud-os-config,True,GAPIC_AUTO,False -google-cloud-os-login,True,GAPIC_AUTO,False -google-cloud-parallelstore,True,GAPIC_AUTO,False -google-cloud-parametermanager,True,GAPIC_AUTO,False -google-cloud-phishing-protection,True,GAPIC_AUTO,False -google-cloud-policy-troubleshooter,True,GAPIC_AUTO,False -google-cloud-policysimulator,True,GAPIC_AUTO,False -google-cloud-policytroubleshooter-iam,True,GAPIC_AUTO,False -google-cloud-private-ca,True,GAPIC_AUTO,False -google-cloud-private-catalog,True,GAPIC_AUTO,False -google-cloud-privilegedaccessmanager,True,GAPIC_AUTO,False -google-cloud-pubsub,True,Hybrid,True -google-cloud-quotas,True,GAPIC_AUTO,False -google-cloud-rapidmigrationassessment,True,GAPIC_AUTO,False -google-cloud-recaptcha-enterprise,True,GAPIC_AUTO,False -google-cloud-recommendations-ai,True,GAPIC_AUTO,False -google-cloud-recommender,True,GAPIC_AUTO,False -google-cloud-redis,True,GAPIC_AUTO,False -google-cloud-redis-cluster,True,GAPIC_AUTO,False -google-cloud-resource-manager,True,GAPIC_AUTO,False -google-cloud-retail,True,GAPIC_AUTO,False -google-cloud-run,True,GAPIC_AUTO,False -google-cloud-runtimeconfig,False,Handwritten,False -google-cloud-saasplatform-saasservicemgmt,True,GAPIC_AUTO,False -google-cloud-scheduler,True,GAPIC_AUTO,False -google-cloud-secret-manager,True,GAPIC_AUTO,False -google-cloud-securesourcemanager,True,GAPIC_AUTO,False -google-cloud-security-publicca,True,GAPIC_AUTO,False -google-cloud-securitycenter,True,GAPIC_AUTO,False -google-cloud-securitycentermanagement,True,GAPIC_AUTO,False -google-cloud-service-control,True,GAPIC_AUTO,False -google-cloud-service-directory,True,GAPIC_AUTO,False -google-cloud-service-management,True,GAPIC_AUTO,False -google-cloud-service-usage,True,GAPIC_AUTO,False -google-cloud-servicehealth,True,GAPIC_AUTO,False -google-cloud-shell,True,GAPIC_AUTO,False -google-cloud-source-context,True,GAPIC_AUTO,False -google-cloud-spanner,True,Hybrid,True -google-cloud-speech,True,Hybrid,True -google-cloud-storage,True,Hybrid,True -google-cloud-storage-control,True,GAPIC_AUTO,False -google-cloud-storage-transfer,True,GAPIC_AUTO,False -google-cloud-storagebatchoperations,True,GAPIC_AUTO,False -google-cloud-storageinsights,True,GAPIC_AUTO,False -google-cloud-support,True,GAPIC_AUTO,False -google-cloud-talent,True,GAPIC_AUTO,False -google-cloud-tasks,True,GAPIC_AUTO,False -google-cloud-telcoautomation,True,GAPIC_AUTO,False -google-cloud-testutils,False,Handwritten,False -google-cloud-texttospeech,True,GAPIC_AUTO,False -google-cloud-tpu,True,GAPIC_AUTO,False -google-cloud-trace,True,GAPIC_AUTO,False -google-cloud-translate,True,GAPIC_AUTO,False -google-cloud-vectorsearch,True,GAPIC_AUTO,False -google-cloud-video-live-stream,True,GAPIC_AUTO,False -google-cloud-video-stitcher,True,GAPIC_AUTO,False -google-cloud-video-transcoder,True,GAPIC_AUTO,False -google-cloud-videointelligence,True,GAPIC_AUTO,False -google-cloud-vision,True,Hybrid,True -google-cloud-visionai,True,GAPIC_AUTO,False -google-cloud-vm-migration,True,GAPIC_AUTO,False -google-cloud-vmwareengine,True,GAPIC_AUTO,False -google-cloud-vpc-access,True,GAPIC_AUTO,False -google-cloud-webrisk,True,GAPIC_AUTO,False -google-cloud-websecurityscanner,True,GAPIC_AUTO,False -google-cloud-workflows,True,GAPIC_AUTO,False -google-cloud-workloadmanager,True,GAPIC_AUTO,False -google-cloud-workstations,True,GAPIC_AUTO,False -google-crc32c,False,Handwritten,False -google-developer-knowledge,True,GAPIC_AUTO,False -google-devicesandservices-health,True,GAPIC_AUTO,False -google-geo-type,True,GAPIC_AUTO,False -google-maps-addressvalidation,True,GAPIC_AUTO,False -google-maps-areainsights,True,GAPIC_AUTO,False -google-maps-fleetengine,True,GAPIC_AUTO,False -google-maps-fleetengine-delivery,True,GAPIC_AUTO,False -google-maps-geocode,True,GAPIC_AUTO,False -google-maps-mapmanagement,True,GAPIC_AUTO,False -google-maps-mapsplatformdatasets,True,GAPIC_AUTO,False -google-maps-navconnect,True,GAPIC_AUTO,False -google-maps-places,True,GAPIC_AUTO,False -google-maps-routeoptimization,True,GAPIC_AUTO,False -google-maps-routing,True,GAPIC_AUTO,False -google-maps-solar,True,GAPIC_AUTO,False -google-resumable-media,False,Handwritten,False -google-shopping-css,True,GAPIC_AUTO,False -google-shopping-merchant-accounts,True,GAPIC_AUTO,False -google-shopping-merchant-conversions,True,GAPIC_AUTO,False -google-shopping-merchant-datasources,True,GAPIC_AUTO,False -google-shopping-merchant-inventories,True,GAPIC_AUTO,False -google-shopping-merchant-issueresolution,True,GAPIC_AUTO,False -google-shopping-merchant-lfp,True,GAPIC_AUTO,False -google-shopping-merchant-notifications,True,GAPIC_AUTO,False -google-shopping-merchant-ordertracking,True,GAPIC_AUTO,False -google-shopping-merchant-products,True,GAPIC_AUTO,False -google-shopping-merchant-productstudio,True,GAPIC_AUTO,False -google-shopping-merchant-promotions,True,GAPIC_AUTO,False -google-shopping-merchant-quota,True,GAPIC_AUTO,False -google-shopping-merchant-reports,True,GAPIC_AUTO,False -google-shopping-merchant-reviews,True,GAPIC_AUTO,False -google-shopping-type,True,GAPIC_AUTO,False -googleapis-common-protos,True,GAPIC_AUTO,False -grafeas,True,GAPIC_AUTO,False -grpc-google-iam-v1,True,GAPIC_AUTO,False -pandas-gbq,False,Handwritten,False -proto-plus,False,Handwritten,False -sqlalchemy-bigquery,False,Handwritten,False -sqlalchemy-spanner,False,Handwritten,False -google-cloud-spanner-dbapi-driver,False,Handwritten,False From 24c40b4320caca49c3373a0991c67c4f0b2676fb Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Tue, 30 Jun 2026 14:38:17 -0400 Subject: [PATCH 12/18] feat(handwritten): centralize mypy config for all handwritten packages --- packages/bigquery-magics/noxfile.py | 11 +++++++++++ packages/db-dtypes/noxfile.py | 14 +++++++++++++- packages/django-google-spanner/noxfile.py | 11 +++++++++++ packages/gapic-generator/mypy.ini | 2 -- packages/gapic-generator/noxfile.py | 16 +++++++++++++++- packages/gcp-sphinx-docfx-yaml/noxfile.py | 13 +++++++++++++ packages/google-api-core/noxfile.py | 15 ++++++++++++++- packages/google-auth-httplib2/noxfile.py | 14 +++++++++++++- packages/google-auth-oauthlib/noxfile.py | 14 +++++++++++++- packages/google-cloud-bigquery/mypy.ini | 3 --- packages/google-cloud-bigquery/noxfile.py | 15 ++++++++++++++- packages/google-cloud-dns/noxfile.py | 14 +++++++++++++- .../google-cloud-documentai-toolbox/noxfile.py | 14 +++++++++++++- packages/google-cloud-ndb/noxfile.py | 14 +++++++++++++- packages/google-cloud-runtimeconfig/noxfile.py | 14 +++++++++++++- packages/pandas-gbq/noxfile.py | 14 +++++++++++++- packages/proto-plus/noxfile.py | 11 +++++++++++ packages/sqlalchemy-bigquery/noxfile.py | 11 +++++++++++ packages/sqlalchemy-spanner/noxfile.py | 11 +++++++++++ 19 files changed, 215 insertions(+), 16 deletions(-) delete mode 100644 packages/gapic-generator/mypy.ini delete mode 100644 packages/google-cloud-bigquery/mypy.ini diff --git a/packages/bigquery-magics/noxfile.py b/packages/bigquery-magics/noxfile.py index f275406b6905..0ff22a1037e7 100644 --- a/packages/bigquery-magics/noxfile.py +++ b/packages/bigquery-magics/noxfile.py @@ -112,6 +112,17 @@ } 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", diff --git a/packages/db-dtypes/noxfile.py b/packages/db-dtypes/noxfile.py index b80b1df6832a..549f1ed785ce 100644 --- a/packages/db-dtypes/noxfile.py +++ b/packages/db-dtypes/noxfile.py @@ -70,6 +70,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"), +) + # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ @@ -540,7 +551,8 @@ def mypy(session): ) session.install("-e", ".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "db_dtypes", "--check-untyped-defs", diff --git a/packages/django-google-spanner/noxfile.py b/packages/django-google-spanner/noxfile.py index 0b94e5b87bff..7d1d9cecc70f 100644 --- a/packages/django-google-spanner/noxfile.py +++ b/packages/django-google-spanner/noxfile.py @@ -66,6 +66,17 @@ ] 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.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/gapic-generator/mypy.ini b/packages/gapic-generator/mypy.ini deleted file mode 100644 index ecb455a69d99..000000000000 --- a/packages/gapic-generator/mypy.ini +++ /dev/null @@ -1,2 +0,0 @@ -[mypy] -python_version = 3.14 diff --git a/packages/gapic-generator/noxfile.py b/packages/gapic-generator/noxfile.py index 6fac5c48853d..fb8c21e2f2f1 100644 --- a/packages/gapic-generator/noxfile.py +++ b/packages/gapic-generator/noxfile.py @@ -36,6 +36,18 @@ showcase_version = os.environ.get("SHOWCASE_VERSION", "0.35.0") ADS_TEMPLATES = path.join(path.dirname(__file__), "gapic", "ads-templates") +CURRENT_DIRECTORY = 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"), +) + RUFF_VERSION = "ruff==0.14.14" LINT_PATHS = ["docs", "gapic", "tests", "test_utils", "noxfile.py", "setup.py"] # Ruff uses globs for excludes (different from Black's regex) @@ -714,7 +726,9 @@ def mypy(session): "click==8.1.3", ) session.install(".") - session.run("mypy", "-p", "gapic") + session.run( + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "gapic") @nox.session(python=NEWEST_PYTHON) diff --git a/packages/gcp-sphinx-docfx-yaml/noxfile.py b/packages/gcp-sphinx-docfx-yaml/noxfile.py index ba5658c0e24f..c83da80f1973 100644 --- a/packages/gcp-sphinx-docfx-yaml/noxfile.py +++ b/packages/gcp-sphinx-docfx-yaml/noxfile.py @@ -13,11 +13,24 @@ # limitations under the License. import os +import pathlib import nox DEFAULT_PYTHON_VERSION = "3.14" UNIT_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] +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"), +) + RUFF_VERSION = "ruff==0.14.14" ALL_PYTHON = list(UNIT_TEST_PYTHON_VERSIONS) diff --git a/packages/google-api-core/noxfile.py b/packages/google-api-core/noxfile.py index 0bad668a80dd..5c4e76c2b91a 100644 --- a/packages/google-api-core/noxfile.py +++ b/packages/google-api-core/noxfile.py @@ -39,6 +39,17 @@ DEFAULT_PYTHON_VERSION = "3.14" 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"), +) + # Error if a python version is missing @@ -370,7 +381,9 @@ def mypy(session): "types-requests", "types-protobuf", ) - session.run("mypy", "google", "tests") + session.run( + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "google", "tests") @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/google-auth-httplib2/noxfile.py b/packages/google-auth-httplib2/noxfile.py index 67b1bd420cc5..0449ee2dedcb 100644 --- a/packages/google-auth-httplib2/noxfile.py +++ b/packages/google-auth-httplib2/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"), +) + # Error if a python version is missing nox.options.error_on_missing_interpreters = True @@ -100,7 +111,8 @@ def mypy(session): ) session.install(".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "google_auth_httplib2.py", ) diff --git a/packages/google-auth-oauthlib/noxfile.py b/packages/google-auth-oauthlib/noxfile.py index a028eb1f1900..f139f73dc58c 100644 --- a/packages/google-auth-oauthlib/noxfile.py +++ b/packages/google-auth-oauthlib/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"), +) + # Error if a python version is missing nox.options.error_on_missing_interpreters = True @@ -470,7 +481,8 @@ def mypy(session): ) session.install(".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "google_auth_oauthlib", ) diff --git a/packages/google-cloud-bigquery/mypy.ini b/packages/google-cloud-bigquery/mypy.ini deleted file mode 100644 index a3cb5c292172..000000000000 --- a/packages/google-cloud-bigquery/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.14 -namespace_packages = True diff --git a/packages/google-cloud-bigquery/noxfile.py b/packages/google-cloud-bigquery/noxfile.py index c1dd1692b744..7eb0269a7789 100644 --- a/packages/google-cloud-bigquery/noxfile.py +++ b/packages/google-cloud-bigquery/noxfile.py @@ -41,6 +41,17 @@ ALL_PYTHON = ["3.10", "3.11", "3.12", "3.13", "3.14"] UNIT_TEST_PYTHON_VERSIONS = ALL_PYTHON 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"), +) + SYSTEM_TEST_PYTHON_VERSIONS = UNIT_TEST_PYTHON_VERSIONS @@ -215,7 +226,9 @@ def mypy(session): ) session.run("python", "-m", "pip", "freeze") with log_package_context(session): - session.run("mypy", "-p", "google", "--show-traceback") + session.run( + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "google", "--show-traceback") @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) diff --git a/packages/google-cloud-dns/noxfile.py b/packages/google-cloud-dns/noxfile.py index bb38d1e08a91..9d837e2a9bd0 100644 --- a/packages/google-cloud-dns/noxfile.py +++ b/packages/google-cloud-dns/noxfile.py @@ -67,6 +67,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", @@ -154,7 +165,8 @@ def mypy(session): ) session.install(".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "google", ) diff --git a/packages/google-cloud-documentai-toolbox/noxfile.py b/packages/google-cloud-documentai-toolbox/noxfile.py index db70716c5d6b..e771e3ebca96 100644 --- a/packages/google-cloud-documentai-toolbox/noxfile.py +++ b/packages/google-cloud-documentai-toolbox/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", @@ -497,7 +508,8 @@ def mypy(session): ) session.install("-e", ".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "google.cloud.documentai_toolbox", "--check-untyped-defs", diff --git a/packages/google-cloud-ndb/noxfile.py b/packages/google-cloud-ndb/noxfile.py index e447badd711c..3d17e2897d8a 100644 --- a/packages/google-cloud-ndb/noxfile.py +++ b/packages/google-cloud-ndb/noxfile.py @@ -31,6 +31,17 @@ DEFAULT_INTERPRETER = "3.14" ALL_INTERPRETERS = ("3.10", "3.11", "3.12", "3.13", "3.14") 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"), +) + BLACK_VERSION = "black[jupyter]==23.7.0" RUFF_VERSION = "ruff==0.14.14" @@ -534,7 +545,8 @@ def mypy(session): ) session.install("-e", ".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "google.cloud.ndb", "--check-untyped-defs", diff --git a/packages/google-cloud-runtimeconfig/noxfile.py b/packages/google-cloud-runtimeconfig/noxfile.py index 42e77572607e..f570a6355ddb 100644 --- a/packages/google-cloud-runtimeconfig/noxfile.py +++ b/packages/google-cloud-runtimeconfig/noxfile.py @@ -68,6 +68,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"), +) + # Error if a python version is missing nox.options.error_on_missing_interpreters = True @@ -99,7 +110,8 @@ def mypy(session): ) session.install(".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "google", ) diff --git a/packages/pandas-gbq/noxfile.py b/packages/pandas-gbq/noxfile.py index 8e58d09628bc..e7bcacae7420 100644 --- a/packages/pandas-gbq/noxfile.py +++ b/packages/pandas-gbq/noxfile.py @@ -79,6 +79,17 @@ SYSTEM_TEST_EXTRAS_BY_PYTHON = {} 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"), +) + # Error if a python version is missing nox.options.error_on_missing_interpreters = True @@ -543,7 +554,8 @@ def mypy(session): ) session.install(".") session.run( - "mypy", + \"mypy\", + f\"--config-file={MYPY_CONFIG_FILE}\", "pandas_gbq", "--check-untyped-defs", *session.posargs, diff --git a/packages/proto-plus/noxfile.py b/packages/proto-plus/noxfile.py index 4e07083cd49c..5ae48e61efd3 100644 --- a/packages/proto-plus/noxfile.py +++ b/packages/proto-plus/noxfile.py @@ -27,6 +27,17 @@ LINT_PATHS = ["docs", "proto", "tests", "noxfile.py", "setup.py"] 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"), +) + DEFAULT_PYTHON_VERSION = "3.14" diff --git a/packages/sqlalchemy-bigquery/noxfile.py b/packages/sqlalchemy-bigquery/noxfile.py index b1e6b068c872..2a5336d4b37d 100644 --- a/packages/sqlalchemy-bigquery/noxfile.py +++ b/packages/sqlalchemy-bigquery/noxfile.py @@ -119,6 +119,17 @@ } 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"), +) + def _calculate_duration(func): diff --git a/packages/sqlalchemy-spanner/noxfile.py b/packages/sqlalchemy-spanner/noxfile.py index 187d4e7e8924..7670ac29f936 100644 --- a/packages/sqlalchemy-spanner/noxfile.py +++ b/packages/sqlalchemy-spanner/noxfile.py @@ -82,6 +82,17 @@ class = StreamHandler RUFF_VERSION = "ruff==0.14.14" LINT_PATHS = ["google", "tests", "noxfile.py", "setup.py", "samples"] 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"), +) + UNIT_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", From 8992e36c8ca56ec05c713b0c2de1ae01da38c2e2 Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 1 Jul 2026 06:11:53 -0400 Subject: [PATCH 13/18] updates to mypy.ini re: bigtable Intended to bring the root mypy.ini in closer alignment with the previous bigtable mypy.ini --- mypy.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index 4a9a43ab38e3..34efe7028109 100644 --- a/mypy.ini +++ b/mypy.ini @@ -89,12 +89,12 @@ ignore_missing_imports = True # --- google-cloud-bigtable --- [mypy-google.cloud.bigtable.*] -ignore_errors = True - -[mypy-google.cloud.bigtable.data.*] check_untyped_defs = True warn_unreachable = True disallow_any_generics = True +ignore_errors = True + +[mypy-google.cloud.bigtable.data.*] ignore_errors = False # --- bigframes --- From 1fba46605c39d71d9c7d59bc65baa3e451fc0ced Mon Sep 17 00:00:00 2001 From: Chalmer Lowe Date: Wed, 1 Jul 2026 06:38:39 -0400 Subject: [PATCH 14/18] updates mypy.ini to account for several package specific settings. --- mypy.ini | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/mypy.ini b/mypy.ini index 34efe7028109..08181fa4aa2e 100644 --- a/mypy.ini +++ b/mypy.ini @@ -14,7 +14,6 @@ exclude = (?x)( | (^|/)tests/unit/gapic/ ) - # ============================================================================== # GLOBAL THIRD-PARTY & SHARED LIBRARY IGNORES # ============================================================================== @@ -28,15 +27,6 @@ ignore_missing_imports = True [mypy-flask] ignore_missing_imports = True -[mypy-google.auth.*] -ignore_missing_imports = True - -[mypy-google.cloud.bigtable] -ignore_missing_imports = True - -[mypy-google.cloud.pubsub] -ignore_missing_imports = True - [mypy-google.colab] ignore_missing_imports = True @@ -86,8 +76,18 @@ ignore_missing_imports = True # ============================================================================== # PACKAGE-SPECIFIC OVERRIDES & EXCEPTIONS # ============================================================================== +# --- bigframes --- +[mypy-bigframes_vendored.*] +ignore_errors = True + +# --- google-auth --- +[mypy-google.auth.*] +ignore_missing_imports = True # --- google-cloud-bigtable --- +[mypy-google.cloud.bigtable] +ignore_missing_imports = True + [mypy-google.cloud.bigtable.*] check_untyped_defs = True warn_unreachable = True @@ -97,10 +97,6 @@ ignore_errors = True [mypy-google.cloud.bigtable.data.*] ignore_errors = False -# --- bigframes --- -[mypy-bigframes_vendored.*] -ignore_errors = True - # --- google-cloud-datastore --- [mypy-google.cloud.datastore.*] ignore_missing_imports = True @@ -108,12 +104,10 @@ ignore_missing_imports = True [mypy-google.cloud.datastore._app_engine_key_pb2] ignore_errors = True -[mypy-google.cloud.datastore_v1.services.datastore.async_client] -ignore_errors = True - -[mypy-google.cloud.datastore_v1.services.datastore.client] -ignore_errors = True - # --- google-cloud-firestore --- [mypy-google.cloud.firestore.*] check_untyped_defs = True + +# --- google-cloud-pubsub --- +[mypy-google.cloud.pubsub] +ignore_missing_imports = True From 81c42bf6f557618d08509fe6ab3e3d2a99625730 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Wed, 1 Jul 2026 10:47:04 -0400 Subject: [PATCH 15/18] fix: resolve syntax errors in noxfiles due to escaped quotes --- packages/db-dtypes/noxfile.py | 4 ++-- packages/gapic-generator/noxfile.py | 4 ++-- packages/google-api-core/noxfile.py | 4 ++-- packages/google-auth-httplib2/noxfile.py | 4 ++-- packages/google-auth-oauthlib/noxfile.py | 4 ++-- packages/google-cloud-bigquery/noxfile.py | 4 ++-- packages/google-cloud-dns/noxfile.py | 4 ++-- packages/google-cloud-documentai-toolbox/noxfile.py | 4 ++-- packages/google-cloud-ndb/noxfile.py | 4 ++-- packages/google-cloud-runtimeconfig/noxfile.py | 4 ++-- packages/pandas-gbq/noxfile.py | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/db-dtypes/noxfile.py b/packages/db-dtypes/noxfile.py index 549f1ed785ce..afd1ab00a637 100644 --- a/packages/db-dtypes/noxfile.py +++ b/packages/db-dtypes/noxfile.py @@ -551,8 +551,8 @@ def mypy(session): ) session.install("-e", ".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "db_dtypes", "--check-untyped-defs", diff --git a/packages/gapic-generator/noxfile.py b/packages/gapic-generator/noxfile.py index fb8c21e2f2f1..0af9c39e45ed 100644 --- a/packages/gapic-generator/noxfile.py +++ b/packages/gapic-generator/noxfile.py @@ -727,8 +727,8 @@ def mypy(session): ) session.install(".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "gapic") + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "gapic") @nox.session(python=NEWEST_PYTHON) diff --git a/packages/google-api-core/noxfile.py b/packages/google-api-core/noxfile.py index 5c4e76c2b91a..085952612053 100644 --- a/packages/google-api-core/noxfile.py +++ b/packages/google-api-core/noxfile.py @@ -382,8 +382,8 @@ def mypy(session): "types-protobuf", ) session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", "google", "tests") + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "google", "tests") @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/google-auth-httplib2/noxfile.py b/packages/google-auth-httplib2/noxfile.py index 0449ee2dedcb..162301d4f13b 100644 --- a/packages/google-auth-httplib2/noxfile.py +++ b/packages/google-auth-httplib2/noxfile.py @@ -111,8 +111,8 @@ def mypy(session): ) session.install(".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "google_auth_httplib2.py", ) diff --git a/packages/google-auth-oauthlib/noxfile.py b/packages/google-auth-oauthlib/noxfile.py index f139f73dc58c..1a7f043e7461 100644 --- a/packages/google-auth-oauthlib/noxfile.py +++ b/packages/google-auth-oauthlib/noxfile.py @@ -481,8 +481,8 @@ def mypy(session): ) session.install(".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google_auth_oauthlib", ) diff --git a/packages/google-cloud-bigquery/noxfile.py b/packages/google-cloud-bigquery/noxfile.py index 7eb0269a7789..2a2583640fa4 100644 --- a/packages/google-cloud-bigquery/noxfile.py +++ b/packages/google-cloud-bigquery/noxfile.py @@ -227,8 +227,8 @@ def mypy(session): session.run("python", "-m", "pip", "freeze") with log_package_context(session): session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", "-p", "google", "--show-traceback") + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--show-traceback") @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) diff --git a/packages/google-cloud-dns/noxfile.py b/packages/google-cloud-dns/noxfile.py index 9d837e2a9bd0..55c042e6b68f 100644 --- a/packages/google-cloud-dns/noxfile.py +++ b/packages/google-cloud-dns/noxfile.py @@ -165,8 +165,8 @@ def mypy(session): ) session.install(".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", ) diff --git a/packages/google-cloud-documentai-toolbox/noxfile.py b/packages/google-cloud-documentai-toolbox/noxfile.py index e771e3ebca96..d046a6f3d39b 100644 --- a/packages/google-cloud-documentai-toolbox/noxfile.py +++ b/packages/google-cloud-documentai-toolbox/noxfile.py @@ -508,8 +508,8 @@ def mypy(session): ) session.install("-e", ".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google.cloud.documentai_toolbox", "--check-untyped-defs", diff --git a/packages/google-cloud-ndb/noxfile.py b/packages/google-cloud-ndb/noxfile.py index 3d17e2897d8a..93564ffa28e0 100644 --- a/packages/google-cloud-ndb/noxfile.py +++ b/packages/google-cloud-ndb/noxfile.py @@ -545,8 +545,8 @@ def mypy(session): ) session.install("-e", ".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google.cloud.ndb", "--check-untyped-defs", diff --git a/packages/google-cloud-runtimeconfig/noxfile.py b/packages/google-cloud-runtimeconfig/noxfile.py index f570a6355ddb..f4e52787ebf7 100644 --- a/packages/google-cloud-runtimeconfig/noxfile.py +++ b/packages/google-cloud-runtimeconfig/noxfile.py @@ -110,8 +110,8 @@ def mypy(session): ) session.install(".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", ) diff --git a/packages/pandas-gbq/noxfile.py b/packages/pandas-gbq/noxfile.py index e7bcacae7420..aabc6426becb 100644 --- a/packages/pandas-gbq/noxfile.py +++ b/packages/pandas-gbq/noxfile.py @@ -554,8 +554,8 @@ def mypy(session): ) session.install(".") session.run( - \"mypy\", - f\"--config-file={MYPY_CONFIG_FILE}\", + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", "pandas_gbq", "--check-untyped-defs", *session.posargs, From ce4bc4778457d23abb8c335549ff866ef8ab90f9 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Wed, 1 Jul 2026 11:34:53 -0400 Subject: [PATCH 16/18] fix(mypy): add global ignores for grpc_status and google.api --- mypy.ini | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mypy.ini b/mypy.ini index 08181fa4aa2e..a3013d474058 100644 --- a/mypy.ini +++ b/mypy.ini @@ -27,6 +27,9 @@ ignore_missing_imports = True [mypy-flask] ignore_missing_imports = True +[mypy-google.api.*] +ignore_missing_imports = True + [mypy-google.colab] ignore_missing_imports = True @@ -51,6 +54,9 @@ ignore_missing_imports = True [mypy-grpc.*] ignore_missing_imports = True +[mypy-grpc_status] +ignore_missing_imports = True + [mypy-ibis.*] ignore_missing_imports = True From 4def939446f2a47c923a840885a3cc6f543d9123 Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Wed, 1 Jul 2026 11:35:04 -0400 Subject: [PATCH 17/18] fix(mypy): restore ignores for generated bigtable packages --- mypy.ini | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mypy.ini b/mypy.ini index a3013d474058..a6f8d17f0ab3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -103,6 +103,15 @@ ignore_errors = True [mypy-google.cloud.bigtable.data.*] ignore_errors = False +[mypy-google.cloud.bigtable_admin.*] +ignore_errors = True + +[mypy-google.cloud.bigtable_admin_v2.*] +ignore_errors = True + +[mypy-google.cloud.bigtable_v2.*] +ignore_errors = True + # --- google-cloud-datastore --- [mypy-google.cloud.datastore.*] ignore_missing_imports = True From 5a22944c549651f963ee54e863eea51fc361f9af Mon Sep 17 00:00:00 2001 From: chalmer lowe Date: Wed, 1 Jul 2026 17:36:43 -0400 Subject: [PATCH 18/18] chore(tests): apply blacken/ruff formatting to modified noxfiles --- packages/django-google-spanner/noxfile.py | 1 - packages/gapic-generator/noxfile.py | 24 +++++++++------- packages/google-api-core/noxfile.py | 5 +--- packages/google-cloud-bigquery/noxfile.py | 8 ++++-- packages/google-cloud-bigtable/noxfile.py | 4 ++- packages/google-cloud-testutils/noxfile.py | 21 ++++++++------ packages/google-resumable-media/noxfile.py | 33 +++++++++++++++++----- packages/sqlalchemy-bigquery/noxfile.py | 1 - 8 files changed, 62 insertions(+), 35 deletions(-) diff --git a/packages/django-google-spanner/noxfile.py b/packages/django-google-spanner/noxfile.py index 7d1d9cecc70f..dfdeaa49f4a1 100644 --- a/packages/django-google-spanner/noxfile.py +++ b/packages/django-google-spanner/noxfile.py @@ -78,7 +78,6 @@ ) - @nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """Run linters. diff --git a/packages/gapic-generator/noxfile.py b/packages/gapic-generator/noxfile.py index 0af9c39e45ed..a9b1d7fc5bf7 100644 --- a/packages/gapic-generator/noxfile.py +++ b/packages/gapic-generator/noxfile.py @@ -726,9 +726,7 @@ def mypy(session): "click==8.1.3", ) session.install(".") - session.run( - "mypy", - f"--config-file={MYPY_CONFIG_FILE}", "-p", "gapic") + session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "-p", "gapic") @nox.session(python=NEWEST_PYTHON) @@ -740,7 +738,7 @@ def lint(session): """ # TODO(https://github.com/googleapis/google-cloud-python/issues/16186): - # SKIP: This session was not enforced in the standalone (split) repo + # SKIP: This session was not enforced in the standalone (split) repo # and is disabled here to ensure a "move-only" migration. session.skip( "Linting was not enforced in the split repo. " @@ -770,9 +768,11 @@ def lint(session): @nox.session(python=NEWEST_PYTHON) def lint_setup_py(session): # TODO(https://github.com/googleapis/google-cloud-python/issues/16186): - # SKIP: This session was not enforced in the standalone (split) repo + # SKIP: This session was not enforced in the standalone (split) repo # and is disabled here to ensure a "move-only" migration. - session.skip("Skipping now to avoid changing code during migration. See Issue #16186") + session.skip( + "Skipping now to avoid changing code during migration. See Issue #16186" + ) @nox.session(python="3.10") @@ -847,9 +847,11 @@ def prerelease_deps(session, protobuf_implementation): """ Run all tests with pre-release versions of dependencies installed. """ - # TODO(https://github.com/googleapis/google-cloud-python/issues/16184): + # TODO(https://github.com/googleapis/google-cloud-python/issues/16184): # Implement pre-release dependency logic to test against upcoming runtime changes. - session.skip("prerelease_deps session is not yet implemented for gapic-generator-python.") + session.skip( + "prerelease_deps session is not yet implemented for gapic-generator-python." + ) @nox.session(python=NEWEST_PYTHON) @@ -859,6 +861,8 @@ def prerelease_deps(session, protobuf_implementation): ) def core_deps_from_source(session, protobuf_implementation): """Run all tests with core dependencies installed from source.""" - # TODO(https://github.com/googleapis/google-cloud-python/issues/16185): + # TODO(https://github.com/googleapis/google-cloud-python/issues/16185): # Implement logic to install core packages directly from the mono-repo directories. - session.skip("core_deps_from_source session is not yet implemented for gapic-generator-python.") \ No newline at end of file + session.skip( + "core_deps_from_source session is not yet implemented for gapic-generator-python." + ) diff --git a/packages/google-api-core/noxfile.py b/packages/google-api-core/noxfile.py index 085952612053..c2904cfc0261 100644 --- a/packages/google-api-core/noxfile.py +++ b/packages/google-api-core/noxfile.py @@ -51,7 +51,6 @@ ) - # Error if a python version is missing nox.options.error_on_missing_interpreters = True @@ -381,9 +380,7 @@ def mypy(session): "types-requests", "types-protobuf", ) - session.run( - "mypy", - f"--config-file={MYPY_CONFIG_FILE}", "google", "tests") + session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "google", "tests") @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/google-cloud-bigquery/noxfile.py b/packages/google-cloud-bigquery/noxfile.py index 2a2583640fa4..d4accfea91a4 100644 --- a/packages/google-cloud-bigquery/noxfile.py +++ b/packages/google-cloud-bigquery/noxfile.py @@ -227,8 +227,12 @@ def mypy(session): session.run("python", "-m", "pip", "freeze") with log_package_context(session): session.run( - "mypy", - f"--config-file={MYPY_CONFIG_FILE}", "-p", "google", "--show-traceback") + "mypy", + f"--config-file={MYPY_CONFIG_FILE}", + "-p", + "google", + "--show-traceback", + ) @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) diff --git a/packages/google-cloud-bigtable/noxfile.py b/packages/google-cloud-bigtable/noxfile.py index dbc582ebaab1..25b94d7b6ab4 100644 --- a/packages/google-cloud-bigtable/noxfile.py +++ b/packages/google-cloud-bigtable/noxfile.py @@ -186,7 +186,9 @@ def mypy(session): "types-requests", ) session.install("google-cloud-testutils") - session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "-p", "google.cloud.bigtable.data") + session.run( + "mypy", f"--config-file={MYPY_CONFIG_FILE}", "-p", "google.cloud.bigtable.data" + ) @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/packages/google-cloud-testutils/noxfile.py b/packages/google-cloud-testutils/noxfile.py index 7716dd6c4d2d..caebbf8ef459 100644 --- a/packages/google-cloud-testutils/noxfile.py +++ b/packages/google-cloud-testutils/noxfile.py @@ -42,12 +42,15 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) - @nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """Run linters. @@ -87,8 +90,10 @@ def format(session): # 2. Run Ruff to fix imports session.run( - "ruff", "check", - "--select", "I", + "ruff", + "check", + "--select", + "I", "--fix", f"--target-version=py{ALL_PYTHON[0].replace('.', '')}", "--line-length=88", @@ -97,7 +102,8 @@ def format(session): # 3. Run Ruff to format code session.run( - "ruff", "format", + "ruff", + "format", f"--target-version=py{ALL_PYTHON[0].replace('.', '')}", "--line-length=88", *BLACK_PATHS, @@ -120,8 +126,7 @@ def mypy(session): "types-mock", "types-setuptools", ) - session.run("mypy", - f"--config-file={MYPY_CONFIG_FILE}", "test_utils/", "tests/") + session.run("mypy", f"--config-file={MYPY_CONFIG_FILE}", "test_utils/", "tests/") @nox.session(python=ALL_PYTHON) @@ -336,14 +341,12 @@ def prerelease_deps(session): ) - @nox.session(python=DEFAULT_PYTHON_VERSION) def core_deps_from_source(session): """Run all tests with core dependencies installed from source rather than pulling the dependencies from PyPI. """ - # Install all dependencies constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" diff --git a/packages/google-resumable-media/noxfile.py b/packages/google-resumable-media/noxfile.py index 3ad5b9fd948b..6d0f35f30375 100644 --- a/packages/google-resumable-media/noxfile.py +++ b/packages/google-resumable-media/noxfile.py @@ -24,7 +24,11 @@ # 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(p / "mypy.ini") + for p in CURRENT_DIRECTORY.parents + if (p / "mypy.ini").exists() + ), str(CURRENT_DIRECTORY.parent.parent / "mypy.ini"), ) @@ -75,7 +79,7 @@ def unit(session): line_coverage, os.path.join("tests", "unit"), os.path.join("tests_async", "unit"), - *session.posargs + *session.posargs, ) @@ -113,6 +117,7 @@ def docs(session): os.path.join("docs", "_build", "html", ""), ) + @nox.session(python="3.10") def docfx(session): """Build the docfx yaml files for this library.""" @@ -258,8 +263,16 @@ def mypy(session): "types-requests", "types-mock", ) - 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=SYSTEM_TEST_PYTHON_VERSIONS) @@ -327,7 +340,9 @@ def prerelease_deps(session): # version, the first version we test with in the unit tests sessions has a # constraints file containing all dependencies and extras. with open( - CURRENT_DIRECTORY / "testing" / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", + CURRENT_DIRECTORY + / "testing" + / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", encoding="utf-8", ) as constraints_file: constraints_text = constraints_file.read() @@ -408,7 +423,9 @@ def core_deps_from_source(session): # version, the first version we test with in the unit tests sessions has a # constraints file containing all dependencies and extras. with open( - CURRENT_DIRECTORY / "testing" / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", + CURRENT_DIRECTORY + / "testing" + / f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", encoding="utf-8", ) as constraints_file: constraints_text = constraints_file.read() @@ -439,7 +456,9 @@ def core_deps_from_source(session): dep_paths = [str(deps_dir / dep) for dep in core_dependencies_from_source] session.install(*dep_paths, "--no-deps", "--ignore-installed") - print(f"Installed {', '.join(core_dependencies_from_source)} locally from {deps_dir}") + print( + f"Installed {', '.join(core_dependencies_from_source)} locally from {deps_dir}" + ) other_deps = [ "cryptography", diff --git a/packages/sqlalchemy-bigquery/noxfile.py b/packages/sqlalchemy-bigquery/noxfile.py index 2a5336d4b37d..0588ec4893e2 100644 --- a/packages/sqlalchemy-bigquery/noxfile.py +++ b/packages/sqlalchemy-bigquery/noxfile.py @@ -131,7 +131,6 @@ ) - def _calculate_duration(func): """This decorator prints the execution time for the decorated function."""