Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,6 @@ replacements:
"google-cloud-core >= 2.0.0, <3.0.0",
"grpcio >= 1.59.0, < 2.0.0",
count: 1
- paths: [
"packages/google-cloud-datastore/mypy.ini",
]
before: |-
# Performance: reuse results from previous runs to speed up 'nox'
incremental = True
after: |-
# 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
count: 1
- paths: [
"packages/google-cloud-datastore/mypy.ini",
]
before: |
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
after: |
ignore_missing_imports = True
count: 1
- paths: [
"packages/google-cloud-datastore/docs/index.rst",
]
Expand Down
93 changes: 93 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[mypy]
namespace_packages = True
ignore_missing_imports = False

# Helps mypy navigate the "google" namespace more reliably in 3.10+
explicit_package_bases = True

# Performance: reuse results from previous runs to speed up "nox"
incremental = True

exclude = (?x)(
^third_party/
| tests/unit/resources/
| tests/unit/gapic/
)
Comment on lines +11 to +15

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The exclude pattern uses ^third_party/ which only matches if third_party/ is at the root of the search path. When running mypy from individual package directories (e.g., via nox), or if a package has its own nested third_party directory, this anchor will prevent it from matching. Using (^|/) makes the exclusion patterns robust and consistent regardless of whether mypy is executed from the repository root or from a package subdirectory.

exclude = (?x)(
    (^|/)third_party/
  | (^|/)tests/unit/resources/
  | (^|/)tests/unit/gapic/
  )


# TODO(https://github.com/googleapis/gapic-generator-python/issues/2563):
# Dependencies that historically lacks py.typed markers
[mypy-google.iam.*]
ignore_missing_imports = True

[mypy-google.type.*]
ignore_missing_imports = True


# ==============================================================================
# PACKAGE-SPECIFIC OVERRIDES
# ==============================================================================

# --- google-cloud-core ---
[mypy-google.protobuf.*]
ignore_missing_imports = True

# --- bigframes ---
[mypy-cloudpickle.*]
ignore_missing_imports = True
[mypy-flask]
ignore_missing_imports = True
[mypy-pydata_google_auth]
ignore_missing_imports = True
[mypy-google.colab]
ignore_missing_imports = True
[mypy-pytz]
ignore_missing_imports = True
[mypy-pyarrow.*]
ignore_missing_imports = True
[mypy-ibis.*]
ignore_missing_imports = True
[mypy-ipywidgets]
ignore_missing_imports = True
[mypy-google.cloud.pubsub]
ignore_missing_imports = True
[mypy-google.cloud.bigtable]
ignore_missing_imports = True
[mypy-anywidget]
ignore_missing_imports = True

# --- google-cloud-bigtable ---
[mypy-google.cloud.bigtable.*]
check_untyped_defs = True
warn_unreachable = True
disallow_any_generics = True
ignore_errors = True

[mypy-google.cloud.bigtable.data.*]
ignore_errors = False
Comment on lines +59 to +66

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting strictness flags like check_untyped_defs, warn_unreachable, and disallow_any_generics under [mypy-google.cloud.bigtable.*] is redundant because ignore_errors = True is also set for that pattern, which silences all errors. If these strictness flags were intended to apply to the non-ignored [mypy-google.cloud.bigtable.data.*] submodule, they should be moved to that section instead.

[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 = False


[mypy-grpc.*]
ignore_missing_imports = True
[mypy-google.auth.*]
ignore_missing_imports = True
[mypy-google.longrunning.*]
ignore_missing_imports = True
[mypy-google.oauth2.*]
ignore_missing_imports = True
[mypy-google.rpc.*]
ignore_missing_imports = True
[mypy-proto.*]
ignore_missing_imports = True
[mypy-pytest]
ignore_missing_imports = True

# --- google-cloud-datastore ---
[mypy-google.cloud.datastore._app_engine_key_pb2]
ignore_errors = True

# TODO(https://github.com/googleapis/gapic-generator-python/issues/2410):
# Remove once this generator bug is fixed
[mypy-google.cloud.datastore_v1.services.datastore.async_client]
ignore_errors = True

[mypy-google.cloud.datastore_v1.services.datastore.client]
ignore_errors = True
3 changes: 0 additions & 3 deletions packages/gapic-generator/gapic/ads-templates/mypy.ini.j2

This file was deleted.

7 changes: 7 additions & 0 deletions packages/gapic-generator/gapic/ads-templates/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
{% block content %}

import os
import pathlib

import nox # type: ignore


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")


# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
# Add tests for Python 3.15 alpha1
# https://peps.python.org/pep-0790/
Expand Down Expand Up @@ -44,6 +50,7 @@ def mypy(session):
session.install('.')
session.run(
'mypy',
f"--config-file={MYPY_CONFIG_FILE}",
{% if api.naming.module_namespace %}
'{{ api.naming.module_namespace[0] }}',
{% else %}
Expand Down
15 changes: 0 additions & 15 deletions packages/gapic-generator/gapic/templates/mypy.ini.j2

This file was deleted.

3 changes: 3 additions & 0 deletions packages/gapic-generator/gapic/templates/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ DEFAULT_PYTHON_VERSION = "3.14"
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 = (
Expand Down Expand Up @@ -101,6 +103,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
{% if api.naming.module_namespace %}
"{{ api.naming.module_namespace[0] }}",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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 = (
Expand Down Expand Up @@ -108,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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 = (
Expand Down Expand Up @@ -108,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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 = (
Expand Down Expand Up @@ -108,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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 = (
Expand Down Expand Up @@ -108,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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 = (
Expand Down Expand Up @@ -108,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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 = (
Expand Down Expand Up @@ -108,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down
Loading
Loading