Navigation Menu

Skip to content

Commit

Permalink
feat: add type hints for public methods (#613)
Browse files Browse the repository at this point in the history
* feat: add type hint for public methods

* feat: add bigquery-storage in requirement file

* feat: add pandas in requirement file

* feat: add return type hint

* feat: remove pandas import as a string

* Use the latest pytype version (2021.4.9)

* Silence false import and module attribute errors

* Fix misc. pytype warnings and false postiives

* Make changes to generated files persistent

* Make final cleanup of client.py

* Change import ignores to more specific errors

* Silence false positive type warning in job config

* Silence noisy _helper type warnings

* Silence false positives for resumable media code

* Add pytype to nox.options.sessions

* Hide for-type-check-only imports behind a flag

* Remove obsolete skipIf decorator from two tests

inspect.signature() was added in Python 3.3, and the library only
needs to suppport Python3.6+.

* Install dependencies in pytype session

This avoids numerous unnecessary import and module attribute errors,
rendering lots of pytype directive comments obsolete.

* Be more specific about to_dataframe()'s return type

* Add missing return type for _get_query_results()

* Be more specific about pandas/pyarrow return types

* Exclude typing-only imports from coverage checks

Co-authored-by: HemangChothani <hemang.chothani@qlogic.io>
Co-authored-by: Tim Swast <swast@google.com>
  • Loading branch information
3 people committed Apr 23, 2021
1 parent 34ecc3f commit f8d4aaa
Show file tree
Hide file tree
Showing 21 changed files with 575 additions and 331 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -29,6 +29,7 @@ pip-log.txt
.nox
.cache
.pytest_cache
.pytype


# Mac
Expand Down
3 changes: 1 addition & 2 deletions google/cloud/bigquery/_http.py
Expand Up @@ -17,8 +17,7 @@
import os
import pkg_resources

from google.cloud import _http

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


Expand Down
2 changes: 2 additions & 0 deletions google/cloud/bigquery/_pandas_helpers.py
Expand Up @@ -373,6 +373,7 @@ def augment_schema(dataframe, current_bq_schema):
Returns:
Optional[Sequence[google.cloud.bigquery.schema.SchemaField]]
"""
# pytype: disable=attribute-error
augmented_schema = []
unknown_type_fields = []

Expand Down Expand Up @@ -406,6 +407,7 @@ def augment_schema(dataframe, current_bq_schema):
return None

return augmented_schema
# pytype: enable=attribute-error


def dataframe_to_arrow(dataframe, bq_schema):
Expand Down

0 comments on commit f8d4aaa

Please sign in to comment.