From d254f4de9ce0e559df7969b330e4164e7d1000e7 Mon Sep 17 00:00:00 2001 From: Jared Chapman Date: Fri, 6 Jan 2023 11:36:30 -0600 Subject: [PATCH 1/2] chore: install all sample dependencies when type checking samples --- google/__init__.py | 2 +- google/cloud/bigquery/opentelemetry_tracing.py | 6 +++--- noxfile.py | 16 +++++++++++++--- samples/mypy.ini | 1 - 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/google/__init__.py b/google/__init__.py index 8fcc60e2b..8e60d8439 100644 --- a/google/__init__.py +++ b/google/__init__.py @@ -21,4 +21,4 @@ except ImportError: import pkgutil - __path__ = pkgutil.extend_path(__path__, __name__) + __path__ = pkgutil.extend_path(__path__, __name__) # type: ignore diff --git a/google/cloud/bigquery/opentelemetry_tracing.py b/google/cloud/bigquery/opentelemetry_tracing.py index 2345fd1bb..3d0a66ba8 100644 --- a/google/cloud/bigquery/opentelemetry_tracing.py +++ b/google/cloud/bigquery/opentelemetry_tracing.py @@ -18,9 +18,9 @@ logger = logging.getLogger(__name__) try: - from opentelemetry import trace - from opentelemetry.instrumentation.utils import http_status_to_status_code - from opentelemetry.trace.status import Status + from opentelemetry import trace # type: ignore + from opentelemetry.instrumentation.utils import http_status_to_status_code # type: ignore + from opentelemetry.trace.status import Status # type: ignore HAS_OPENTELEMETRY = True _warned_telemetry = True diff --git a/noxfile.py b/noxfile.py index a91e60a5f..8c6a80792 100644 --- a/noxfile.py +++ b/noxfile.py @@ -200,19 +200,29 @@ def mypy_samples(session): """Run type checks with mypy.""" session.install("-e", ".[all]") - session.install("ipython", "pytest") + session.install("pytest") + for requirements_path in CURRENT_DIRECTORY.glob("samples/*/requirements.txt"): + session.install("-r", requirements_path) session.install(MYPY_VERSION) # Just install the dependencies' type info directly, since "mypy --install-types" # might require an additional pass. - session.install("types-mock", "types-pytz") + session.install( + "types-mock", + "types-pytz", + "types-protobuf", + "types-python-dateutil", + "types-requests", + "types-setuptools", + ) + session.install("typing-extensions") # for TypedDict in pre-3.8 Python versions session.run( "mypy", "--config-file", str(CURRENT_DIRECTORY / "samples" / "mypy.ini"), - "--no-incremental", # Required by warn-unused-configs from mypy.ini to work + "--no-incremental", # Required by warn-unused-configs from mypy.ini to work "samples/", ) diff --git a/samples/mypy.ini b/samples/mypy.ini index 29757e47d..3f7eb6647 100644 --- a/samples/mypy.ini +++ b/samples/mypy.ini @@ -2,7 +2,6 @@ # Should match DEFAULT_PYTHON_VERSION from root noxfile.py python_version = 3.8 exclude = noxfile\.py -strict = True warn_unused_configs = True [mypy-google.auth,google.oauth2,geojson,google_auth_oauthlib,IPython.*] From ce6fce1c1c37c59accb4d204f70956cb487dec03 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 6 Jan 2023 17:42:37 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 8c6a80792..139093acc 100644 --- a/noxfile.py +++ b/noxfile.py @@ -208,7 +208,7 @@ def mypy_samples(session): # Just install the dependencies' type info directly, since "mypy --install-types" # might require an additional pass. session.install( - "types-mock", + "types-mock", "types-pytz", "types-protobuf", "types-python-dateutil", @@ -222,7 +222,7 @@ def mypy_samples(session): "mypy", "--config-file", str(CURRENT_DIRECTORY / "samples" / "mypy.ini"), - "--no-incremental", # Required by warn-unused-configs from mypy.ini to work + "--no-incremental", # Required by warn-unused-configs from mypy.ini to work "samples/", )