Skip to content

Commit 1ebfd2b

Browse files
authored
Merge branch 'main' into feat-dataset-view
2 parents a20c4e2 + b863291 commit 1ebfd2b

File tree

10 files changed

+25
-33
lines changed

10 files changed

+25
-33
lines changed

google/cloud/bigquery/external_config.py

Lines changed: 5 additions & 4 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,10 +836,10 @@ 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 = self._properties.get("schema", {}) # type: ignore
841-
return [SchemaField.from_api_repr(field) for field in prop.get("fields", [])] # type: ignore
839+
prop: Dict[str, Any] = typing.cast(
840+
Dict[str, Any], self._properties.get("schema", {})
841+
)
842+
return [SchemaField.from_api_repr(field) for field in prop.get("fields", [])]
842843

843844
@schema.setter
844845
def schema(self, value):

google/cloud/bigquery/job/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,7 @@ 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
440-
configuration = self._CONFIG_CLASS() # pytype: disable=not-callable
438+
configuration: _JobConfig = self._CONFIG_CLASS() # pytype: disable=not-callable
441439
configuration._properties = self._properties.setdefault("configuration", {})
442440
return configuration
443441

google/cloud/bigquery/routine/routine.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -518,23 +518,17 @@ 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
523-
return self._properties["projectId"] # pytype: disable=typed-dict-error
521+
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
530-
return self._properties["datasetId"] # pytype: disable=typed-dict-error
526+
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
537-
return self._properties["routineId"] # pytype: disable=typed-dict-error
531+
return self._properties.get("routineId", "")
538532

539533
@property
540534
def path(self):

google/cloud/bigquery/schema.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,9 @@ 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
237235
self._properties["policyTags"] = (
238-
policy_tags.to_api_repr() # pytype: disable=attribute-error
239-
if policy_tags is not None
236+
policy_tags.to_api_repr()
237+
if isinstance(policy_tags, PolicyTagList)
240238
else None
241239
)
242240
if isinstance(range_element_type, str):

google/cloud/bigquery/table.py

Lines changed: 6 additions & 5 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):
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
@@ -151,15 +151,16 @@ def _view_use_legacy_sql_getter(table):
151151
ValueError: For invalid value types.
152152
"""
153153

154-
view = table._properties.get("view") # type: ignore
154+
view: Optional[Dict[str, Any]] = table._properties.get("view")
155155
if view is not None:
156156
# The server-side default for useLegacySql is True.
157-
return view.get("useLegacySql", True) # type: ignore
157+
return view.get("useLegacySql", True) if view is not None else True
158158
# In some cases, such as in a table list no view object is present, but the
159159
# resource still represents a view. Use the type as a fallback.
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:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
google-cloud-bigquery==3.33.0
1+
google-cloud-bigquery==3.34.0
22
google-auth-oauthlib==1.2.2

samples/geography/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ geojson==3.2.0
1212
geopandas==1.0.1
1313
google-api-core==2.24.2
1414
google-auth==2.40.2
15-
google-cloud-bigquery==3.33.0
16-
google-cloud-bigquery-storage==2.31.0
15+
google-cloud-bigquery==3.34.0
16+
google-cloud-bigquery-storage==2.32.0
1717
google-cloud-core==2.4.3
1818
google-crc32c==1.7.1
1919
google-resumable-media==2.7.2

samples/magics/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
bigquery_magics==0.10.0
22
db-dtypes==1.4.3
3-
google.cloud.bigquery==3.33.0
4-
google-cloud-bigquery-storage==2.31.0
3+
google.cloud.bigquery==3.34.0
4+
google-cloud-bigquery-storage==2.32.0
55
ipython===8.18.1
66
pandas==2.2.3

samples/notebooks/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
bigquery-magics==0.10.0
22
db-dtypes==1.4.3
3-
google-cloud-bigquery==3.33.0
4-
google-cloud-bigquery-storage==2.31.0
3+
google-cloud-bigquery==3.34.0
4+
google-cloud-bigquery-storage==2.32.0
55
ipython===8.18.1; python_version == '3.9'
66
ipython==9.2.0; python_version >= '3.10'
77
matplotlib===3.9.2; python_version == '3.9'

samples/snippets/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# samples/snippets should be runnable with no "extras"
2-
google-cloud-bigquery==3.33.0
2+
google-cloud-bigquery==3.34.0

0 commit comments

Comments
 (0)