Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 447472a

Browse files
committed
tweaks type hinting
1 parent ae2cb44 commit 447472a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

google/cloud/bigquery/dataset.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ def __init__(
300300
entity_id: Optional[Union[Dict[str, Any], str]] = None,
301301
**kwargs,
302302
):
303-
self._properties = {}
303+
self._properties: Dict[str, Any] = {}
304304
if entity_type is not None:
305305
self._properties[entity_type] = entity_id
306306
self._properties["role"] = role
307-
self._entity_type = entity_type
307+
self._entity_type: Optional[str] = entity_type
308308
for prop, val in kwargs.items():
309309
setattr(self, prop, val)
310310

@@ -491,9 +491,13 @@ def entity_type(self) -> Optional[str]:
491491
@property
492492
def entity_id(self) -> Optional[Union[Dict[str, Any], str]]:
493493
"""The entity_id of the entry."""
494+
if self.entity_type:
495+
entity_type = self.entity_type
496+
else:
497+
return None
494498
return typing.cast(
495499
Optional[Union[Dict[str, Any], str]],
496-
self._properties.get(self.entity_type, None),
500+
self._properties.get(entity_type, None),
497501
)
498502

499503
def __eq__(self, other):

0 commit comments

Comments
 (0)