Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5f807f0
feat: add type hint for public methods
HemangChothani Dec 22, 2020
6a84a87
feat: add bigquery-storage in requirement file
HemangChothani Dec 22, 2020
887ec27
feat: add pandas in requirement file
HemangChothani Dec 22, 2020
984d8a0
feat: add return type hint
HemangChothani Dec 24, 2020
63a5729
feat: remove pandas import as a string
HemangChothani Dec 28, 2020
c9fd3b7
Use the latest pytype version (2021.4.9)
plamut Apr 15, 2021
61cb93c
Silence false import and module attribute errors
plamut Apr 15, 2021
c17993e
Fix misc. pytype warnings and false postiives
plamut Apr 15, 2021
b76029c
Make changes to generated files persistent
plamut Apr 15, 2021
558163d
Make final cleanup of client.py
plamut Apr 15, 2021
b3a9054
Change import ignores to more specific errors
plamut Apr 15, 2021
5529b34
Silence false positive type warning in job config
plamut Apr 15, 2021
7762366
Silence noisy _helper type warnings
plamut Apr 15, 2021
bf32b2c
Silence false positives for resumable media code
plamut Apr 19, 2021
5f672f9
Add pytype to nox.options.sessions
plamut Apr 19, 2021
0afc6ca
Hide for-type-check-only imports behind a flag
plamut Apr 21, 2021
3bdc7d8
Remove obsolete skipIf decorator from two tests
plamut Apr 21, 2021
8466b33
Install dependencies in pytype session
plamut Apr 21, 2021
dfd4317
Be more specific about to_dataframe()'s return type
plamut Apr 21, 2021
3a449d2
Add missing return type for _get_query_results()
plamut Apr 21, 2021
80820f7
Be more specific about pandas/pyarrow return types
plamut Apr 21, 2021
055d9f5
Exclude typing-only imports from coverage checks
plamut Apr 21, 2021
3c00aa5
Merge branch 'master' into iss-157
tswast Apr 23, 2021
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
Prev Previous commit
Next Next commit
Change import ignores to more specific errors
  • Loading branch information
plamut committed Apr 15, 2021
commit b3a9054dd5d05ccfadcb07826c310b9af973b367
16 changes: 10 additions & 6 deletions google/cloud/bigquery/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
import decimal
import re

from google.cloud._helpers import UTC # type: ignore
from google.cloud._helpers import _date_from_iso8601_date # type: ignore
from google.cloud._helpers import _datetime_from_microseconds # type: ignore
from google.cloud._helpers import _RFC3339_MICROS # type: ignore
from google.cloud._helpers import _RFC3339_NO_FRACTION # type: ignore
from google.cloud._helpers import _to_bytes # type: ignore
from google.cloud._helpers import UTC # pytype: disable=import-error
from google.cloud._helpers import ( # pytype: disable=import-error
_date_from_iso8601_date,
)
from google.cloud._helpers import ( # pytype: disable=import-error
_datetime_from_microseconds,
)
from google.cloud._helpers import _RFC3339_MICROS # pytype: disable=import-error
from google.cloud._helpers import _RFC3339_NO_FRACTION # pytype: disable=import-error
from google.cloud._helpers import _to_bytes # pytype: disable=import-error

_RFC3339_MICROS_NO_ZULU = "%Y-%m-%dT%H:%M:%S.%f"
_TIMEONLY_WO_MICROS = "%H:%M:%S"
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os
import pkg_resources

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


Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigquery/_pandas_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
from packaging import version # pytype: disable=import-error

try:
import pandas # type: ignore
import pandas # pytype: disable=import-error
except ImportError: # pragma: NO COVER
pandas = None

try:
import pyarrow # type: ignore
import pyarrow.parquet # type: ignore
import pyarrow # pytype: disable=import-error
import pyarrow.parquet # pytype: disable=import-error
except ImportError: # pragma: NO COVER
pyarrow = None

Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/_tqdm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import warnings

try:
import tqdm # type: ignore
import tqdm # pytype: disable=import-error
except ImportError: # pragma: NO COVER
tqdm = None

Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import google.api_core.exceptions as core_exceptions # pytype: disable=import-error
from google.api_core.iam import Policy # pytype: disable=import-error
from google.api_core import page_iterator # pytype: disable=import-error
from google.api_core import retry as retries # type: ignore
from google.api_core import retry as retries # pytype: disable=import-error
import google.cloud._helpers
from google.cloud import exceptions # pytype: disable=import-error
from google.cloud.client import ClientWithProject # pytype: disable=import-error
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigquery/dbapi/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from google.cloud.bigquery import job
from google.cloud.bigquery.dbapi import _helpers
from google.cloud.bigquery.dbapi import exceptions
import google.cloud.exceptions # type: ignore
import google.cloud.exceptions # pytype: disable=import-error


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -195,7 +195,7 @@ def execute(self, operation, parameters=None, job_id=None, job_config=None):
# Wait for the query to finish.
try:
self._query_job.result()
except google.cloud.exceptions.GoogleCloudError as exc:
except google.cloud.exceptions.GoogleCloudError as exc: # pytype: disable=module-attr
raise exceptions.DatabaseError(exc)

query_results = self._query_job._query_results
Expand Down Expand Up @@ -257,7 +257,7 @@ def _bqstorage_fetch(self, bqstorage_client):
"""
# Hitting this code path with a BQ Storage client instance implies that
# bigquery_storage can indeed be imported here without errors.
from google.cloud import bigquery_storage # type: ignore
from google.cloud import bigquery_storage # pytype: disable=import-error

table_reference = self._query_job.destination

Expand Down
14 changes: 8 additions & 6 deletions google/cloud/bigquery/job/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import http
import threading

from google.api_core import exceptions # type: ignore
import google.api_core.future.polling # type: ignore
from google.api_core import exceptions # pytype: disable=import-error
import google.api_core.future.polling # pytype: disable=import-error

from google.cloud.bigquery import _helpers
from google.cloud.bigquery.retry import DEFAULT_RETRY

# Types needed only for Type Hints
from google.api_core import retry as retries # type: ignore
from google.api_core import retry as retries # pytype: disable=import-error


_DONE_STATE = "DONE"
Expand Down Expand Up @@ -131,7 +131,9 @@ def _from_api_repr(cls, resource):
return job_ref


class _AsyncJob(google.api_core.future.polling.PollingFuture):
class _AsyncJob(
google.api_core.future.polling.PollingFuture # pytype: disable=module-attr
):
"""Base class for asynchronous jobs.

Args:
Expand Down Expand Up @@ -834,7 +836,7 @@ def _fill_from_default(self, default_job_config):
+ repr(default_job_config._job_type)
)

new_job_config = self.__class__() # type: ignore
new_job_config = self.__class__() # pytype: disable=import-error

default_job_properties = copy.deepcopy(default_job_config._properties)
for key in self._properties:
Expand All @@ -858,7 +860,7 @@ def from_api_repr(cls, resource: dict) -> "_JobConfig":
Returns:
google.cloud.bigquery.job._JobConfig: Configuration parsed from ``resource``.
"""
job_config = cls() # type: ignore
job_config = cls() # pytype: disable=import-error
job_config._properties = resource
return job_config

Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigquery/job/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
from google.cloud.bigquery.job.base import _JobReference

# Types needed only for Type Hints
from google.api_core import retry as retries # type: ignore
from google.cloud import bigquery_storage # type: ignore
from google.api_core import retry as retries # pytype: disable=import-error
from google.cloud import bigquery_storage # pytype: disable=import-error
from google.cloud.bigquery.table import RowIterator
from typing import Any, Dict, Union

Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigquery/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

from google.protobuf import json_format

import google.cloud._helpers # type: ignore
from google.api_core import datetime_helpers # type: ignore
import google.cloud._helpers # pytype: disable=import-error
from google.api_core import datetime_helpers # pytype: disable=import-error
from google.cloud.bigquery import _helpers
from google.cloud.bigquery_v2 import types
from google.cloud.bigquery.encryption_configuration import EncryptionConfiguration
Expand Down
12 changes: 8 additions & 4 deletions google/cloud/bigquery/opentelemetry_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@

import logging
from contextlib import contextmanager
from google.api_core.exceptions import GoogleAPICallError # type: ignore
from google.api_core.exceptions import ( # pytype: disable=import-error
GoogleAPICallError,
)

logger = logging.getLogger(__name__)
try:
from opentelemetry import trace # type: ignore
from opentelemetry.instrumentation.utils import http_status_to_canonical_code # type: ignore
from opentelemetry.trace.status import Status # type: ignore
from opentelemetry import trace # pytype: disable=import-error
from opentelemetry.instrumentation.utils import ( # pytype: disable=import-error
http_status_to_canonical_code,
)
from opentelemetry.trace.status import Status # pytype: disable=import-error

HAS_OPENTELEMETRY = True
_warned_telemetry = True
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigquery/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from google.api_core import exceptions # type: ignore
from google.api_core import retry # type: ignore
from google.api_core import exceptions # pytype: disable=import-error
from google.api_core import retry # pytype: disable=import-error
import requests.exceptions


Expand Down
10 changes: 5 additions & 5 deletions google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
import warnings

try:
import pandas # type: ignore
import pandas # pytype: disable=import-error
except ImportError: # pragma: NO COVER
pandas = None

try:
import pyarrow # type: ignore
import pyarrow # pytype: disable=import-error
except ImportError: # pragma: NO COVER
pyarrow = None

import google.api_core.exceptions
from google.api_core.page_iterator import HTTPIterator # type: ignore
from google.api_core.page_iterator import HTTPIterator # pytype: disable=import-error

import google.cloud._helpers # type: ignore
import google.cloud._helpers # pytype: disable=import-error
from google.cloud.bigquery import _helpers
from google.cloud.bigquery import _pandas_helpers
from google.cloud.bigquery.schema import _build_schema_resource
Expand All @@ -48,7 +48,7 @@
from google.cloud.bigquery.encryption_configuration import EncryptionConfiguration

# Types needed only for Type Hints
from google.cloud import bigquery_storage # type: ignore
from google.cloud import bigquery_storage # pytype: disable=import-error
Comment thread
plamut marked this conversation as resolved.
Outdated
from typing import Any, Dict, Iterable, Tuple


Expand Down