Skip to content

Commit 18510c7

Browse files
plamuttswastgcf-owl-bot[bot]
authored andcommitted
process: make mypy happy with type annotations (googleapis#1036)
* process: add mypy types check to nox sessions * Ignore type errors for not annotated modules Several dependencies lack type annotations, or they don't advertise themselves as type-annotated. We do not want `mypy` to complain about these. * Fix mypy complaints (batch 1) * Fix mypy complaints (batch 2) * Fix mypy complaints (batch 3) * Fix mypy false positive errors * Simplify external config options instantiation * Do not ignore api-core in type checks More recent releases of google-api-core have typing enabled. * Remove unneeded __hash__ = None lines * Use an alias for timeout type in client.py * Fix PathLike subscription error in pre-Python 3.9 * Fix a typo in docstring Co-authored-by: Tim Swast <[email protected]> * Add mypy to the list of nox sessions to run * Fix opentelemetry type error The Opentelemetry APi has changed from the minimum version the BigQuery client currently uses, we thus need to bound the maximum Opentelemetry version. In addition, that maximum version does not yet support type checks, thus it is ignored. * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Exclude type-checking code from coverage * Fix patching opentelemetry tracer pvoider * Adjust get_job() return type, ignore opentelemetry Co-authored-by: Tim Swast <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent d969516 commit 18510c7

23 files changed

+220
-182
lines changed

google/cloud/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
except ImportError:
2222
import pkgutil
2323

24-
__path__ = pkgutil.extend_path(__path__, __name__)
24+
__path__ = pkgutil.extend_path(__path__, __name__) # type: ignore

google/cloud/bigquery/_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from typing import Any, Optional, Union
2323

2424
from dateutil import relativedelta
25-
from google.cloud._helpers import UTC
25+
from google.cloud._helpers import UTC # type: ignore
2626
from google.cloud._helpers import _date_from_iso8601_date
2727
from google.cloud._helpers import _datetime_from_microseconds
2828
from google.cloud._helpers import _RFC3339_MICROS
@@ -126,7 +126,7 @@ def __init__(self):
126126
def installed_version(self) -> packaging.version.Version:
127127
"""Return the parsed version of pyarrow."""
128128
if self._installed_version is None:
129-
import pyarrow
129+
import pyarrow # type: ignore
130130

131131
self._installed_version = packaging.version.parse(
132132
# Use 0.0.0, since it is earlier than any released version.

google/cloud/bigquery/_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818
import pkg_resources
1919

20-
from google.cloud import _http # pytype: disable=import-error
20+
from google.cloud import _http # type: ignore # pytype: disable=import-error
2121
from google.cloud.bigquery import __version__
2222

2323

google/cloud/bigquery/_pandas_helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
import warnings
2222

2323
try:
24-
import pandas
24+
import pandas # type: ignore
2525
except ImportError: # pragma: NO COVER
2626
pandas = None
2727
else:
2828
import numpy
2929

3030
try:
3131
# _BaseGeometry is used to detect shapely objevys in `bq_to_arrow_array`
32-
from shapely.geometry.base import BaseGeometry as _BaseGeometry
32+
from shapely.geometry.base import BaseGeometry as _BaseGeometry # type: ignore
3333
except ImportError: # pragma: NO COVER
3434
# No shapely, use NoneType for _BaseGeometry as a placeholder.
3535
_BaseGeometry = type(None)
@@ -43,7 +43,7 @@ def _to_wkb():
4343
# - Avoid extra work done by `shapely.wkb.dumps` that we don't need.
4444
# - Caches the WKBWriter (and write method lookup :) )
4545
# - Avoids adding WKBWriter, lgeos, and notnull to the module namespace.
46-
from shapely.geos import WKBWriter, lgeos
46+
from shapely.geos import WKBWriter, lgeos # type: ignore
4747

4848
write = WKBWriter(lgeos).write
4949
notnull = pandas.notnull
@@ -574,7 +574,7 @@ def dataframe_to_parquet(
574574
"""
575575
pyarrow = _helpers.PYARROW_VERSIONS.try_import(raise_if_error=True)
576576

577-
import pyarrow.parquet
577+
import pyarrow.parquet # type: ignore
578578

579579
kwargs = (
580580
{"use_compliant_nested_type": parquet_use_compliant_nested_type}

google/cloud/bigquery/_tqdm_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import warnings
2222

2323
try:
24-
import tqdm
24+
import tqdm # type: ignore
2525
except ImportError: # pragma: NO COVER
2626
tqdm = None
2727

0 commit comments

Comments
 (0)