Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: annotate optional integer parameters with optional type #1487

Merged
merged 4 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 0 additions & 12 deletions google/cloud/bigquery/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,10 @@

"""Create / interact with Google BigQuery connections."""

import os
import pkg_resources

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


# TODO: Increase the minimum version of google-cloud-core to 1.6.0
# and remove this logic. See:
# https://github.com/googleapis/python-bigquery/issues/509
if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE") == "true": # pragma: NO COVER
release = pkg_resources.get_distribution("google-cloud-core").parsed_version
if release < pkg_resources.parse_version("1.6.0"):
raise ImportError("google-cloud-core >= 1.6.0 is required to use mTLS feature")


class Connection(_http.JSONConnection):
"""A connection to Google BigQuery via the JSON REST API.

Expand Down
42 changes: 21 additions & 21 deletions google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ def get_service_account_email(

def list_projects(
self,
max_results: int = None,
max_results: Optional[int] = None,
page_token: str = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
page_size: int = None,
page_size: Optional[int] = None,
) -> page_iterator.Iterator:
"""List projects for the project associated with this client.

Expand Down Expand Up @@ -395,11 +395,11 @@ def list_datasets(
project: str = None,
include_all: bool = False,
filter: str = None,
max_results: int = None,
max_results: Optional[int] = None,
page_token: str = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
page_size: int = None,
page_size: Optional[int] = None,
) -> page_iterator.Iterator:
"""List datasets for the project associated with this client.

Expand Down Expand Up @@ -1324,11 +1324,11 @@ def update_table(
def list_models(
self,
dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
max_results: int = None,
max_results: Optional[int] = None,
page_token: str = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
page_size: int = None,
page_size: Optional[int] = None,
) -> page_iterator.Iterator:
"""[Beta] List models in the dataset.

Expand Down Expand Up @@ -1401,11 +1401,11 @@ def api_request(*args, **kwargs):
def list_routines(
self,
dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
max_results: int = None,
max_results: Optional[int] = None,
page_token: str = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
page_size: int = None,
page_size: Optional[int] = None,
) -> page_iterator.Iterator:
"""[Beta] List routines in the dataset.

Expand Down Expand Up @@ -1478,11 +1478,11 @@ def api_request(*args, **kwargs):
def list_tables(
self,
dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
max_results: int = None,
max_results: Optional[int] = None,
page_token: str = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
page_size: int = None,
page_size: Optional[int] = None,
) -> page_iterator.Iterator:
"""List tables in the dataset.

Expand Down Expand Up @@ -1838,7 +1838,7 @@ def _get_query_results(
job_id: str,
retry: retries.Retry,
project: str = None,
timeout_ms: int = None,
timeout_ms: Optional[int] = None,
location: str = None,
timeout: TimeoutType = DEFAULT_TIMEOUT,
) -> _QueryResults:
Expand Down Expand Up @@ -2163,15 +2163,15 @@ def list_jobs(
self,
project: str = None,
parent_job: Optional[Union[QueryJob, str]] = None,
max_results: int = None,
max_results: Optional[int] = None,
page_token: str = None,
all_users: bool = None,
state_filter: str = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
min_creation_time: datetime.datetime = None,
max_creation_time: datetime.datetime = None,
page_size: int = None,
page_size: Optional[int] = None,
) -> page_iterator.Iterator:
"""List jobs for the project associated with this client.

Expand Down Expand Up @@ -2361,7 +2361,7 @@ def load_table_from_file(
file_obj: IO[bytes],
destination: Union[Table, TableReference, TableListItem, str],
rewind: bool = False,
size: int = None,
size: Optional[int] = None,
num_retries: int = _DEFAULT_NUM_RETRIES,
job_id: str = None,
job_id_prefix: str = None,
Expand Down Expand Up @@ -3729,10 +3729,10 @@ def list_rows(
self,
table: Union[Table, TableListItem, TableReference, str],
selected_fields: Sequence[SchemaField] = None,
max_results: int = None,
max_results: Optional[int] = None,
page_token: str = None,
start_index: int = None,
page_size: int = None,
start_index: Optional[int] = None,
page_size: Optional[int] = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
) -> RowIterator:
Expand Down Expand Up @@ -3840,11 +3840,11 @@ def _list_rows_from_query_results(
location: str,
project: str,
schema: SchemaField,
total_rows: int = None,
total_rows: Optional[int] = None,
destination: Union[Table, TableReference, TableListItem, str] = None,
max_results: int = None,
start_index: int = None,
page_size: int = None,
max_results: Optional[int] = None,
start_index: Optional[int] = None,
page_size: Optional[int] = None,
retry: retries.Retry = DEFAULT_RETRY,
timeout: TimeoutType = DEFAULT_TIMEOUT,
) -> RowIterator:
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigquery/job/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,11 +1381,11 @@ def _done_or_raise(self, retry=DEFAULT_RETRY, timeout=None):

def result( # type: ignore # (complaints about the overloaded signature)
self,
page_size: int = None,
max_results: int = None,
page_size: Optional[int] = None,
max_results: Optional[int] = None,
retry: "retries.Retry" = DEFAULT_RETRY,
timeout: float = None,
start_index: int = None,
start_index: Optional[int] = None,
job_retry: "retries.Retry" = DEFAULT_JOB_RETRY,
) -> Union["RowIterator", _EmptyRowIterator]:
"""Start the job and wait for it to complete and get the result.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# NOTE: Maintainers, please do not require google-cloud-core>=2.x.x
# Until this issue is closed
# https://github.com/googleapis/google-cloud-python/issues/10566
"google-cloud-core >= 1.4.1, <3.0.0dev",
"google-cloud-core >= 1.6.0, <3.0.0dev",
"google-resumable-media >= 0.6.0, < 3.0dev",
"packaging >= 20.0.0",
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", # For the legacy proto-based types.
Expand Down
2 changes: 1 addition & 1 deletion testing/constraints-3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ db-dtypes==0.3.0
geopandas==0.9.0
google-api-core==1.31.5
google-cloud-bigquery-storage==2.0.0
google-cloud-core==1.4.1
google-cloud-core==1.6.0
google-resumable-media==0.6.0
grpcio==1.47.0
ipywidgets==7.7.1
Expand Down