Skip to content
Merged
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
100 changes: 100 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
[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/
)


# ==============================================================================
# GLOBAL THIRD-PARTY & SHARED LIBRARY IGNORES
# ==============================================================================

[mypy-anywidget]
ignore_missing_imports = True

[mypy-cloudpickle.*]
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

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

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

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

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

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

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

[mypy-grpc.*]
ignore_missing_imports = True

[mypy-ibis.*]
ignore_missing_imports = True

[mypy-ipywidgets]
ignore_missing_imports = True

[mypy-proto.*]
ignore_missing_imports = True

[mypy-pyarrow.*]
ignore_missing_imports = True

[mypy-pydata_google_auth]
ignore_missing_imports = True

[mypy-pytest]
ignore_missing_imports = True

[mypy-pytz]
ignore_missing_imports = True


# ==============================================================================
# PACKAGE-SPECIFIC OVERRIDES & EXCEPTIONS
# ==============================================================================

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


3 changes: 0 additions & 3 deletions packages/gapic-generator/gapic/ads-templates/mypy.ini.j2

This file was deleted.

9 changes: 9 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,9 +3,17 @@
{% block content %}

import os
import pathlib

import nox # type: ignore

CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
# 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"),
)


# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
# Add tests for Python 3.15 alpha1
Expand Down Expand Up @@ -44,6 +52,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.

7 changes: 7 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,12 @@ 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.
# 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"
PACKAGE_NAME = "{{ api.naming.warehouse_package_name }}"
Expand Down Expand Up @@ -96,6 +102,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
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ def _overwrite_golden_impl(ctx):
golden_update_script_content = """
cd ${{BUILD_WORKSPACE_DIRECTORY}}
# Filename pattern-based removal is needed to preserve the BUILD.bazel file.
find tests/integration/goldens/{api_name}/ -name \\*.py-type f -delete
find tests/integration/goldens/{api_name}/ -name \\*.py -type f -delete
find tests/integration/goldens/{api_name}/ -name \\*.json -type f -delete
find tests/integration/goldens/{api_name}/ -name \\*.ini -type f -delete
unzip -ao {goldens_output_zip} -d tests/integration/goldens/{api_name}
""".format(
goldens_output_zip = goldens_output_zip.path,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
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"),
)

LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
PACKAGE_NAME = "google-cloud-asset"
Expand Down Expand Up @@ -103,6 +109,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,12 @@
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"),
)

LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
PACKAGE_NAME = "google-iam-credentials"
Expand Down Expand Up @@ -103,6 +109,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,12 @@
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"),
)

LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
PACKAGE_NAME = "google-cloud-eventarc"
Expand Down Expand Up @@ -103,6 +109,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,12 @@
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"),
)

LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
PACKAGE_NAME = "google-cloud-logging"
Expand Down Expand Up @@ -103,6 +109,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,12 @@
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"),
)

LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
PACKAGE_NAME = "google-cloud-logging"
Expand Down Expand Up @@ -103,6 +109,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.

Loading
Loading