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

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

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


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

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

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

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

[mypy-google.cloud.bigtable.data.*]
ignore_errors = False

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

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

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

[mypy-google.cloud.datastore_v1.services.datastore.client]
ignore_errors = True
46 changes: 0 additions & 46 deletions packages/bigframes/mypy.ini

This file was deleted.

4 changes: 4 additions & 0 deletions packages/bigframes/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1086,6 +1089,7 @@ def mypy(session):
shutil.rmtree(".mypy_cache", ignore_errors=True)
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"bigframes",
os.path.join("tests", "system"),
os.path.join("tests", "unit"),
Expand Down
3 changes: 0 additions & 3 deletions packages/bigquery-magics/mypy.ini

This file was deleted.

3 changes: 0 additions & 3 deletions packages/google-auth/mypy.ini

This file was deleted.

14 changes: 13 additions & 1 deletion packages/google-auth/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -156,7 +159,16 @@ 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)
Expand Down
15 changes: 0 additions & 15 deletions packages/google-backstory/mypy.ini

This file was deleted.

4 changes: 4 additions & 0 deletions packages/google-backstory/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -107,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down
15 changes: 0 additions & 15 deletions packages/google-cloud-appengine-logging/mypy.ini

This file was deleted.

4 changes: 4 additions & 0 deletions packages/google-cloud-appengine-logging/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -107,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down
15 changes: 0 additions & 15 deletions packages/google-cloud-bigquery-logging/mypy.ini

This file was deleted.

4 changes: 4 additions & 0 deletions packages/google-cloud-bigquery-logging/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -107,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down
15 changes: 0 additions & 15 deletions packages/google-cloud-common/mypy.ini

This file was deleted.

4 changes: 4 additions & 0 deletions packages/google-cloud-common/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -107,6 +110,7 @@ def mypy(session):
session.install(".")
session.run(
"mypy",
f"--config-file={MYPY_CONFIG_FILE}",
"-p",
"google",
"--check-untyped-defs",
Expand Down
7 changes: 0 additions & 7 deletions packages/google-cloud-core/mypy.ini

This file was deleted.

11 changes: 10 additions & 1 deletion packages/google-cloud-core/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 0 additions & 15 deletions packages/google-cloud-iam-logging/mypy.ini

This file was deleted.

4 changes: 4 additions & 0 deletions packages/google-cloud-iam-logging/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -107,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