Skip to content

Commit 7eb279e

Browse files
committed
refactor(firestore): align decode_dict and PipelineResult.data return types with _BSONType
- Annotate decode_dict with Union[dict, Vector, _BSONType]. - Update PipelineResult.data to return dict | Vector | _BSONType | None. - Import _BSONType under TYPE_CHECKING in pipeline_result.py. Towards #18402
1 parent faa42fd commit 7eb279e

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/google-cloud-firestore/google/cloud/firestore_v1/_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def _decode_bson_dict_recursive(data: Any) -> Any:
431431
def decode_dict(
432432
value_fields,
433433
client=None,
434-
) -> Union[dict, Vector, _BSONType, bytes]:
434+
) -> Union[dict, Vector, _BSONType]:
435435
"""Converts a protobuf map of Firestore ``Value``-s.
436436
437437
Args:
@@ -442,7 +442,7 @@ def decode_dict(
442442
443443
Returns:
444444
Union[dict, ~google.cloud.firestore_v1.vector.Vector, \
445-
~google.cloud.firestore_v1.bson._BSONType, bytes]: A dictionary of native \
445+
~google.cloud.firestore_v1.bson._BSONType]: A dictionary of native \
446446
Python values, Vector, or BSON object converted from ``value_fields``.
447447
"""
448448
value_fields_pb = getattr(value_fields, "_pb", value_fields)

packages/google-cloud-firestore/google/cloud/firestore_v1/pipeline_result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from google.cloud.firestore_v1.async_transaction import AsyncTransaction
4545
from google.cloud.firestore_v1.base_client import BaseClient
4646
from google.cloud.firestore_v1.base_document import BaseDocumentReference
47+
from google.cloud.firestore_v1.bson import _BSONType
4748
from google.cloud.firestore_v1.client import Client
4849
from google.cloud.firestore_v1.pipeline import Pipeline
4950
from google.cloud.firestore_v1.pipeline_expressions import Constant
@@ -138,7 +139,7 @@ def __eq__(self, other: object) -> bool:
138139
return NotImplemented
139140
return (self._ref == other._ref) and (self._fields_pb == other._fields_pb)
140141

141-
def data(self) -> dict | "Vector" | None:
142+
def data(self) -> dict | "Vector" | "_BSONType" | None:
142143
"""
143144
Retrieves all fields in the result.
144145

0 commit comments

Comments
 (0)