Skip to content

Commit 7f0f639

Browse files
committed
updates type hints across the board
1 parent e5d7e83 commit 7f0f639

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

google/cloud/bigquery/external_config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import base64
2424
import copy
25+
import typing
2526
from typing import Any, Dict, FrozenSet, Iterable, Optional, Union
2627

2728
from google.cloud.bigquery._helpers import _to_bytes
@@ -835,9 +836,9 @@ def schema(self):
835836
See
836837
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ExternalDataConfiguration.FIELDS.schema
837838
"""
838-
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
839-
# manage a pytype issue that came up in another PR. See Issue: #2132
840-
prop: Dict[str, Any] = self._properties.get("schema", {})
839+
prop: Dict[str, Any] = typing.cast(
840+
Dict[str, Any], self._properties.get("schema", {})
841+
)
841842
return [SchemaField.from_api_repr(field) for field in prop.get("fields", [])]
842843

843844
@schema.setter

google/cloud/bigquery/job/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,6 @@ def __init__(self, job_id, client):
435435
@property
436436
def configuration(self) -> _JobConfig:
437437
"""Job-type specific configurtion."""
438-
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
439-
# manage a pytype issue that came up in another PR. See Issue: #2132
440438
configuration: _JobConfig = self._CONFIG_CLASS() # pytype: disable=not-callable
441439
configuration._properties = self._properties.setdefault("configuration", {})
442440
return configuration

google/cloud/bigquery/routine/routine.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,22 +518,16 @@ def __init__(self):
518518
@property
519519
def project(self):
520520
"""str: ID of the project containing the routine."""
521-
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
522-
# manage a pytype issue that came up in another PR. See Issue: #2132
523521
return self._properties.get("projectId", "")
524522

525523
@property
526524
def dataset_id(self):
527525
"""str: ID of dataset containing the routine."""
528-
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
529-
# manage a pytype issue that came up in another PR. See Issue: #2132
530526
return self._properties.get("datasetId", "")
531527

532528
@property
533529
def routine_id(self):
534530
"""str: The routine ID."""
535-
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
536-
# manage a pytype issue that came up in another PR. See Issue: #2132
537531
return self._properties.get("routineId", "")
538532

539533
@property

google/cloud/bigquery/schema.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ def __init__(
232232
if max_length is not _DEFAULT_VALUE:
233233
self._properties["maxLength"] = max_length
234234
if policy_tags is not _DEFAULT_VALUE:
235-
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
236-
# manage a pytype issue that came up in another PR. See Issue: #2132
237-
self._properties["policyTags"] = policy_tags.to_api_repr() if policy_tags is not None else None
235+
self._properties["policyTags"] = (
236+
policy_tags.to_api_repr()
237+
if isinstance(policy_tags, PolicyTagList)
238+
else None
239+
)
238240
if isinstance(range_element_type, str):
239241
self._properties["rangeElementType"] = {"type": range_element_type}
240242
if isinstance(range_element_type, FieldElementType):

google/cloud/bigquery/table.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ def _reference_getter(table):
137137
return TableReference(dataset_ref, table.table_id)
138138

139139

140-
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
141-
# manage a pytype issue that came up in another PR. See Issue: #2132
142-
def _view_use_legacy_sql_getter(table: "Table") -> bool:
140+
def _view_use_legacy_sql_getter(
141+
table: Union["Table", "TableListItem"]
142+
) -> Optional[bool]:
143143
"""bool: Specifies whether to execute the view with Legacy or Standard SQL.
144144
145145
This boolean specifies whether to execute the view with Legacy SQL
@@ -160,6 +160,7 @@ def _view_use_legacy_sql_getter(table: "Table") -> bool:
160160
if table.table_type == "VIEW":
161161
# The server-side default for useLegacySql is True.
162162
return True
163+
return None # explicit return statement to appease mypy
163164

164165

165166
class _TableBase:

0 commit comments

Comments
 (0)