Skip to content

Commit a190aaa

Browse files
authored
fix: annotate optional integer parameters with optional type (#1487)
* fix: annotate optional integer parameters with optional type * remove google-cloud-core reference causing type checker issues deps: update minimum google-cloud-core to 1.6.0
1 parent beab7c2 commit a190aaa

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

google/cloud/bigquery/_http.py

-12
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,10 @@
1414

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

17-
import os
18-
import pkg_resources
19-
2017
from google.cloud import _http # type: ignore # pytype: disable=import-error
2118
from google.cloud.bigquery import __version__
2219

2320

24-
# TODO: Increase the minimum version of google-cloud-core to 1.6.0
25-
# and remove this logic. See:
26-
# https://github.com/googleapis/python-bigquery/issues/509
27-
if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE") == "true": # pragma: NO COVER
28-
release = pkg_resources.get_distribution("google-cloud-core").parsed_version
29-
if release < pkg_resources.parse_version("1.6.0"):
30-
raise ImportError("google-cloud-core >= 1.6.0 is required to use mTLS feature")
31-
32-
3321
class Connection(_http.JSONConnection):
3422
"""A connection to Google BigQuery via the JSON REST API.
3523

google/cloud/bigquery/client.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,11 @@ def get_service_account_email(
329329

330330
def list_projects(
331331
self,
332-
max_results: int = None,
332+
max_results: Optional[int] = None,
333333
page_token: str = None,
334334
retry: retries.Retry = DEFAULT_RETRY,
335335
timeout: TimeoutType = DEFAULT_TIMEOUT,
336-
page_size: int = None,
336+
page_size: Optional[int] = None,
337337
) -> page_iterator.Iterator:
338338
"""List projects for the project associated with this client.
339339
@@ -395,11 +395,11 @@ def list_datasets(
395395
project: str = None,
396396
include_all: bool = False,
397397
filter: str = None,
398-
max_results: int = None,
398+
max_results: Optional[int] = None,
399399
page_token: str = None,
400400
retry: retries.Retry = DEFAULT_RETRY,
401401
timeout: TimeoutType = DEFAULT_TIMEOUT,
402-
page_size: int = None,
402+
page_size: Optional[int] = None,
403403
) -> page_iterator.Iterator:
404404
"""List datasets for the project associated with this client.
405405
@@ -1324,11 +1324,11 @@ def update_table(
13241324
def list_models(
13251325
self,
13261326
dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
1327-
max_results: int = None,
1327+
max_results: Optional[int] = None,
13281328
page_token: str = None,
13291329
retry: retries.Retry = DEFAULT_RETRY,
13301330
timeout: TimeoutType = DEFAULT_TIMEOUT,
1331-
page_size: int = None,
1331+
page_size: Optional[int] = None,
13321332
) -> page_iterator.Iterator:
13331333
"""[Beta] List models in the dataset.
13341334
@@ -1401,11 +1401,11 @@ def api_request(*args, **kwargs):
14011401
def list_routines(
14021402
self,
14031403
dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
1404-
max_results: int = None,
1404+
max_results: Optional[int] = None,
14051405
page_token: str = None,
14061406
retry: retries.Retry = DEFAULT_RETRY,
14071407
timeout: TimeoutType = DEFAULT_TIMEOUT,
1408-
page_size: int = None,
1408+
page_size: Optional[int] = None,
14091409
) -> page_iterator.Iterator:
14101410
"""[Beta] List routines in the dataset.
14111411
@@ -1478,11 +1478,11 @@ def api_request(*args, **kwargs):
14781478
def list_tables(
14791479
self,
14801480
dataset: Union[Dataset, DatasetReference, DatasetListItem, str],
1481-
max_results: int = None,
1481+
max_results: Optional[int] = None,
14821482
page_token: str = None,
14831483
retry: retries.Retry = DEFAULT_RETRY,
14841484
timeout: TimeoutType = DEFAULT_TIMEOUT,
1485-
page_size: int = None,
1485+
page_size: Optional[int] = None,
14861486
) -> page_iterator.Iterator:
14871487
"""List tables in the dataset.
14881488
@@ -1838,7 +1838,7 @@ def _get_query_results(
18381838
job_id: str,
18391839
retry: retries.Retry,
18401840
project: str = None,
1841-
timeout_ms: int = None,
1841+
timeout_ms: Optional[int] = None,
18421842
location: str = None,
18431843
timeout: TimeoutType = DEFAULT_TIMEOUT,
18441844
) -> _QueryResults:
@@ -2163,15 +2163,15 @@ def list_jobs(
21632163
self,
21642164
project: str = None,
21652165
parent_job: Optional[Union[QueryJob, str]] = None,
2166-
max_results: int = None,
2166+
max_results: Optional[int] = None,
21672167
page_token: str = None,
21682168
all_users: bool = None,
21692169
state_filter: str = None,
21702170
retry: retries.Retry = DEFAULT_RETRY,
21712171
timeout: TimeoutType = DEFAULT_TIMEOUT,
21722172
min_creation_time: datetime.datetime = None,
21732173
max_creation_time: datetime.datetime = None,
2174-
page_size: int = None,
2174+
page_size: Optional[int] = None,
21752175
) -> page_iterator.Iterator:
21762176
"""List jobs for the project associated with this client.
21772177
@@ -2361,7 +2361,7 @@ def load_table_from_file(
23612361
file_obj: IO[bytes],
23622362
destination: Union[Table, TableReference, TableListItem, str],
23632363
rewind: bool = False,
2364-
size: int = None,
2364+
size: Optional[int] = None,
23652365
num_retries: int = _DEFAULT_NUM_RETRIES,
23662366
job_id: str = None,
23672367
job_id_prefix: str = None,
@@ -3729,10 +3729,10 @@ def list_rows(
37293729
self,
37303730
table: Union[Table, TableListItem, TableReference, str],
37313731
selected_fields: Sequence[SchemaField] = None,
3732-
max_results: int = None,
3732+
max_results: Optional[int] = None,
37333733
page_token: str = None,
3734-
start_index: int = None,
3735-
page_size: int = None,
3734+
start_index: Optional[int] = None,
3735+
page_size: Optional[int] = None,
37363736
retry: retries.Retry = DEFAULT_RETRY,
37373737
timeout: TimeoutType = DEFAULT_TIMEOUT,
37383738
) -> RowIterator:
@@ -3840,11 +3840,11 @@ def _list_rows_from_query_results(
38403840
location: str,
38413841
project: str,
38423842
schema: SchemaField,
3843-
total_rows: int = None,
3843+
total_rows: Optional[int] = None,
38443844
destination: Union[Table, TableReference, TableListItem, str] = None,
3845-
max_results: int = None,
3846-
start_index: int = None,
3847-
page_size: int = None,
3845+
max_results: Optional[int] = None,
3846+
start_index: Optional[int] = None,
3847+
page_size: Optional[int] = None,
38483848
retry: retries.Retry = DEFAULT_RETRY,
38493849
timeout: TimeoutType = DEFAULT_TIMEOUT,
38503850
) -> RowIterator:

google/cloud/bigquery/job/query.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1381,11 +1381,11 @@ def _done_or_raise(self, retry=DEFAULT_RETRY, timeout=None):
13811381

13821382
def result( # type: ignore # (complaints about the overloaded signature)
13831383
self,
1384-
page_size: int = None,
1385-
max_results: int = None,
1384+
page_size: Optional[int] = None,
1385+
max_results: Optional[int] = None,
13861386
retry: "retries.Retry" = DEFAULT_RETRY,
13871387
timeout: float = None,
1388-
start_index: int = None,
1388+
start_index: Optional[int] = None,
13891389
job_retry: "retries.Retry" = DEFAULT_JOB_RETRY,
13901390
) -> Union["RowIterator", _EmptyRowIterator]:
13911391
"""Start the job and wait for it to complete and get the result.

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# NOTE: Maintainers, please do not require google-cloud-core>=2.x.x
4040
# Until this issue is closed
4141
# https://github.com/googleapis/google-cloud-python/issues/10566
42-
"google-cloud-core >= 1.4.1, <3.0.0dev",
42+
"google-cloud-core >= 1.6.0, <3.0.0dev",
4343
"google-resumable-media >= 0.6.0, < 3.0dev",
4444
"packaging >= 20.0.0",
4545
"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.

testing/constraints-3.7.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ db-dtypes==0.3.0
99
geopandas==0.9.0
1010
google-api-core==1.31.5
1111
google-cloud-bigquery-storage==2.0.0
12-
google-cloud-core==1.4.1
12+
google-cloud-core==1.6.0
1313
google-resumable-media==0.6.0
1414
grpcio==1.47.0
1515
ipywidgets==7.7.1

0 commit comments

Comments
 (0)