Skip to content

Commit

Permalink
chore: install all sample dependencies when type checking samples (go…
Browse files Browse the repository at this point in the history
  • Loading branch information
thejaredchapman authored and abdelmegahedgoogle committed Apr 17, 2023
1 parent 4a401ef commit 06856db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion google/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
__path__ = pkgutil.extend_path(__path__, __name__) # type: ignore
6 changes: 3 additions & 3 deletions google/cloud/bigquery/opentelemetry_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,22 @@ 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(
Expand Down
1 change: 0 additions & 1 deletion samples/mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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.*]
Expand Down

0 comments on commit 06856db

Please sign in to comment.