Skip to content

Commit a8ced8f

Browse files
committed
Addressed review feedback
1 parent d85f2f0 commit a8ced8f

File tree

14 files changed

+189
-99
lines changed

14 files changed

+189
-99
lines changed

google/cloud/firestore_v1/aggregation.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"""
2121
from __future__ import annotations
2222

23-
from datetime import datetime
23+
import datetime
24+
2425
from typing import TYPE_CHECKING, Any, Generator, List, Optional, Union
2526

2627
from google.api_core import exceptions, gapic_v1
@@ -57,7 +58,7 @@ def get(
5758
timeout: float | None = None,
5859
*,
5960
explain_options: Optional[ExplainOptions] = None,
60-
read_time: Optional[datetime] = None,
61+
read_time: Optional[datetime.datetime] = None,
6162
) -> QueryResultsList[AggregationResult]:
6263
"""Runs the aggregation query.
6364
@@ -80,10 +81,11 @@ def get(
8081
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
8182
Options to enable query profiling for this query. When set,
8283
explain_metrics will be available on the returned generator.
83-
read_time (Optional[datetime]): If set, reads documents as they were at the given
84-
time. This must be a microsecond precision timestamp within the past one hour,
85-
or if Point-in-Time Recovery is enabled, can additionally be a whole minute
86-
timestamp within the past 7 days.
84+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
85+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
86+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
87+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
88+
8789
8890
Returns:
8991
QueryResultsList[AggregationResult]: The aggregation query results.
@@ -142,7 +144,7 @@ def _make_stream(
142144
retry: Union[retries.Retry, None, object] = gapic_v1.method.DEFAULT,
143145
timeout: Optional[float] = None,
144146
explain_options: Optional[ExplainOptions] = None,
145-
read_time: Optional[datetime] = None,
147+
read_time: Optional[datetime.datetime] = None,
146148
) -> Generator[List[AggregationResult], Any, Optional[ExplainMetrics]]:
147149
"""Internal method for stream(). Runs the aggregation query.
148150
@@ -166,10 +168,10 @@ def _make_stream(
166168
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
167169
Options to enable query profiling for this query. When set,
168170
explain_metrics will be available on the returned generator.
169-
read_time (Optional[datetime]): If set, reads documents as they were at the given
170-
time. This must be a microsecond precision timestamp within the past one hour,
171-
or if Point-in-Time Recovery is enabled, can additionally be a whole minute
172-
timestamp within the past 7 days.
171+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
172+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
173+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
174+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
173175
174176
Yields:
175177
List[AggregationResult]:
@@ -224,7 +226,7 @@ def stream(
224226
timeout: Optional[float] = None,
225227
*,
226228
explain_options: Optional[ExplainOptions] = None,
227-
read_time: Optional[datetime] = None,
229+
read_time: Optional[datetime.datetime] = None,
228230
) -> StreamGenerator[List[AggregationResult]]:
229231
"""Runs the aggregation query.
230232
@@ -248,10 +250,10 @@ def stream(
248250
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
249251
Options to enable query profiling for this query. When set,
250252
explain_metrics will be available on the returned generator.
251-
read_time (Optional[datetime]): If set, reads documents as they were at the given
252-
time. This must be a microsecond precision timestamp within the past one hour,
253-
or if Point-in-Time Recovery is enabled, can additionally be a whole minute
254-
timestamp within the past 7 days.
253+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
254+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
255+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
256+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
255257
256258
Returns:
257259
`StreamGenerator[List[AggregationResult]]`:

google/cloud/firestore_v1/base_aggregation.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
from __future__ import annotations
2222

2323
import abc
24+
import datetime
25+
2426
from abc import ABC
25-
from datetime import datetime
2627
from typing import TYPE_CHECKING, Any, Coroutine, List, Optional, Tuple, Union
2728

2829
from google.api_core import gapic_v1
@@ -206,7 +207,7 @@ def _prep_stream(
206207
retry: Union[retries.Retry, retries.AsyncRetry, None, object] = None,
207208
timeout: float | None = None,
208209
explain_options: Optional[ExplainOptions] = None,
209-
read_time: Optional[datetime] = None,
210+
read_time: Optional[datetime.datetime] = None,
210211
) -> Tuple[dict, dict]:
211212
parent_path, expected_prefix = self._collection_ref._parent_info()
212213
request = {
@@ -232,7 +233,7 @@ def get(
232233
timeout: float | None = None,
233234
*,
234235
explain_options: Optional[ExplainOptions] = None,
235-
read_time: Optional[datetime] = None,
236+
read_time: Optional[datetime.datetime] = None,
236237
) -> (
237238
QueryResultsList[AggregationResult]
238239
| Coroutine[Any, Any, List[List[AggregationResult]]]
@@ -258,10 +259,10 @@ def get(
258259
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
259260
Options to enable query profiling for this query. When set,
260261
explain_metrics will be available on the returned generator.
261-
read_time (Optional[datetime]): If set, reads documents as they were at the given
262-
time. This must be a microsecond precision timestamp within the past one hour,
263-
or if Point-in-Time Recovery is enabled, can additionally be a whole minute
264-
timestamp within the past 7 days.
262+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
263+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
264+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
265+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
265266
266267
Returns:
267268
(QueryResultsList[List[AggregationResult]] | Coroutine[Any, Any, List[List[AggregationResult]]]):
@@ -279,7 +280,7 @@ def stream(
279280
timeout: Optional[float] = None,
280281
*,
281282
explain_options: Optional[ExplainOptions] = None,
282-
read_time: Optional[datetime] = None,
283+
read_time: Optional[datetime.datetime] = None,
283284
) -> (
284285
StreamGenerator[List[AggregationResult]]
285286
| AsyncStreamGenerator[List[AggregationResult]]
@@ -301,10 +302,10 @@ def stream(
301302
(Optional[:class:`~google.cloud.firestore_v1.query_profile.ExplainOptions`]):
302303
Options to enable query profiling for this query. When set,
303304
explain_metrics will be available on the returned generator.
304-
read_time (Optional[datetime]): If set, reads documents as they were at the given
305-
time. This must be a microsecond precision timestamp within the past one hour,
306-
or if Point-in-Time Recovery is enabled, can additionally be a whole minute
307-
timestamp within the past 7 days.
305+
read_time (Optional[datetime.datetime]): If set, reads documents as they were at the given
306+
time. This must be a timestamp within the past one hour, or if Point-in-Time Recovery
307+
is enabled, can additionally be a whole minute timestamp within the past 7 days. If no
308+
timezone is specified in the :class:`datetime.datetime` object, it is assumed to be UTC.
308309
309310
Returns:
310311
StreamGenerator[List[AggregationResult]] | AsyncStreamGenerator[List[AggregationResult]]:

google/cloud/firestore_v1/base_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"""
2626
from __future__ import annotations
2727

28+
import datetime
2829
import os
29-
from datetime import datetime
3030
from typing import (
3131
Any,
3232
AsyncGenerator,
@@ -438,7 +438,7 @@ def _prep_get_all(
438438
transaction: BaseTransaction | None = None,
439439
retry: retries.Retry | retries.AsyncRetry | object | None = None,
440440
timeout: float | None = None,
441-
read_time: datetime | None = None,
441+
read_time: Optional[datetime.datetime] = None,
442442
) -> Tuple[dict, dict, dict]:
443443
"""Shared setup for async/sync :meth:`get_all`."""
444444
document_paths, reference_map = _reference_info(references)
@@ -463,7 +463,7 @@ def get_all(
463463
retry: retries.Retry | retries.AsyncRetry | object | None = None,
464464
timeout: float | None = None,
465465
*,
466-
read_time: datetime | None = None,
466+
read_time: Optional[datetime.datetime] = None,
467467
) -> Union[
468468
AsyncGenerator[DocumentSnapshot, Any], Generator[DocumentSnapshot, Any, Any]
469469
]:
@@ -473,7 +473,7 @@ def _prep_collections(
473473
self,
474474
retry: retries.Retry | retries.AsyncRetry | object | None = None,
475475
timeout: float | None = None,
476-
read_time: datetime | None = None,
476+
read_time: Optional[datetime.datetime] = None,
477477
) -> Tuple[dict, dict]:
478478
"""Shared setup for async/sync :meth:`collections`."""
479479
request = {
@@ -490,7 +490,7 @@ def collections(
490490
retry: retries.Retry | retries.AsyncRetry | object | None = None,
491491
timeout: float | None = None,
492492
*,
493-
read_time: datetime | None = None,
493+
read_time: Optional[datetime.datetime] = None,
494494
):
495495
raise NotImplementedError
496496

google/cloud/firestore_v1/base_collection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"""Classes for representing collections for the Google Cloud Firestore API."""
1616
from __future__ import annotations
1717

18+
import datetime
1819
import random
1920

20-
from datetime import datetime
2121
from typing import (
2222
TYPE_CHECKING,
2323
Any,
@@ -204,7 +204,7 @@ def _prep_list_documents(
204204
page_size: Optional[int] = None,
205205
retry: retries.Retry | retries.AsyncRetry | object | None = None,
206206
timeout: Optional[float] = None,
207-
read_time: Optional[datetime] = None,
207+
read_time: Optional[datetime.datetime] = None,
208208
) -> Tuple[dict, dict]:
209209
"""Shared setup for async / sync :method:`list_documents`"""
210210
parent, _ = self._parent_info()
@@ -230,7 +230,7 @@ def list_documents(
230230
retry: retries.Retry | retries.AsyncRetry | object | None = None,
231231
timeout: Optional[float] = None,
232232
*,
233-
read_time: Optional[datetime] = None,
233+
read_time: Optional[datetime.datetime] = None,
234234
) -> Union[
235235
Generator[DocumentReference, Any, Any], AsyncGenerator[DocumentReference, Any]
236236
]:
@@ -504,7 +504,7 @@ def get(
504504
timeout: Optional[float] = None,
505505
*,
506506
explain_options: Optional[ExplainOptions] = None,
507-
read_time: Optional[datetime] = None,
507+
read_time: Optional[datetime.datetime] = None,
508508
) -> (
509509
QueryResultsList[DocumentSnapshot]
510510
| Coroutine[Any, Any, QueryResultsList[DocumentSnapshot]]
@@ -518,7 +518,7 @@ def stream(
518518
timeout: Optional[float] = None,
519519
*,
520520
explain_options: Optional[ExplainOptions] = None,
521-
read_time: Optional[datetime] = None,
521+
read_time: Optional[datetime.datetime] = None,
522522
) -> StreamGenerator[DocumentSnapshot] | AsyncIterator[DocumentSnapshot]:
523523
raise NotImplementedError
524524

google/cloud/firestore_v1/base_document.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from __future__ import annotations
1717

1818
import copy
19+
import datetime
20+
1921
from typing import (
2022
TYPE_CHECKING,
2123
Any,
@@ -26,7 +28,6 @@
2628
Union,
2729
Awaitable,
2830
)
29-
from datetime import datetime
3031

3132
from google.api_core import retry as retries
3233

@@ -291,7 +292,7 @@ def _prep_batch_get(
291292
transaction=None,
292293
retry: retries.Retry | retries.AsyncRetry | None | object = None,
293294
timeout: float | None = None,
294-
read_time: datetime | None = None,
295+
read_time: Optional[datetime.datetime] = None,
295296
) -> Tuple[dict, dict]:
296297
"""Shared setup for async/sync :meth:`get`."""
297298
if isinstance(field_paths, str):
@@ -321,7 +322,7 @@ def get(
321322
retry: retries.Retry | retries.AsyncRetry | None | object = None,
322323
timeout: float | None = None,
323324
*,
324-
read_time: Optional[datetime] = None,
325+
read_time: Optional[datetime.datetime] = None,
325326
) -> "DocumentSnapshot" | Awaitable["DocumentSnapshot"]:
326327
raise NotImplementedError
327328

@@ -330,7 +331,7 @@ def _prep_collections(
330331
page_size: int | None = None,
331332
retry: retries.Retry | retries.AsyncRetry | None | object = None,
332333
timeout: float | None = None,
333-
read_time: datetime | None = None,
334+
read_time: Optional[datetime.datetime] = None,
334335
) -> Tuple[dict, dict]:
335336
"""Shared setup for async/sync :meth:`collections`."""
336337
request = {
@@ -349,7 +350,7 @@ def collections(
349350
retry: retries.Retry | retries.AsyncRetry | None | object = None,
350351
timeout: float | None = None,
351352
*,
352-
read_time: Optional[datetime] = None,
353+
read_time: Optional[datetime.datetime] = None,
353354
):
354355
raise NotImplementedError
355356

google/cloud/firestore_v1/base_query.py

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

2323
import abc
2424
import copy
25+
import datetime
2526
import math
2627
import warnings
27-
from datetime import datetime
28+
2829
from typing import (
2930
TYPE_CHECKING,
3031
Any,
@@ -1032,7 +1033,7 @@ def get(
10321033
timeout: Optional[float] = None,
10331034
*,
10341035
explain_options: Optional[ExplainOptions] = None,
1035-
read_time: Optional[datetime] = None,
1036+
read_time: Optional[datetime.datetime] = None,
10361037
) -> (
10371038
QueryResultsList[DocumentSnapshot]
10381039
| Coroutine[Any, Any, QueryResultsList[DocumentSnapshot]]
@@ -1045,7 +1046,7 @@ def _prep_stream(
10451046
retry: retries.Retry | retries.AsyncRetry | object | None = None,
10461047
timeout: Optional[float] = None,
10471048
explain_options: Optional[ExplainOptions] = None,
1048-
read_time: Optional[datetime] = None,
1049+
read_time: Optional[datetime.datetime] = None,
10491050
) -> Tuple[dict, str, dict]:
10501051
"""Shared setup for async / sync :meth:`stream`"""
10511052
if self._limit_to_last:
@@ -1075,7 +1076,7 @@ def stream(
10751076
timeout: Optional[float] = None,
10761077
*,
10771078
explain_options: Optional[ExplainOptions] = None,
1078-
read_time: Optional[datetime] = None,
1079+
read_time: Optional[datetime.datetime] = None,
10791080
) -> (
10801081
StreamGenerator[document.DocumentSnapshot]
10811082
| AsyncStreamGenerator[DocumentSnapshot]
@@ -1432,7 +1433,7 @@ def _prep_get_partitions(
14321433
partition_count,
14331434
retry: retries.Retry | object | None = None,
14341435
timeout: float | None = None,
1435-
read_time: datetime | None = None,
1436+
read_time: Optional[datetime.datetime] = None,
14361437
) -> Tuple[dict, dict]:
14371438
self._validate_partition_query()
14381439
parent_path, expected_prefix = self._parent._parent_info()
@@ -1461,7 +1462,7 @@ def get_partitions(
14611462
retry: Optional[retries.Retry] = None,
14621463
timeout: Optional[float] = None,
14631464
*,
1464-
read_time: Optional[datetime] = None,
1465+
read_time: Optional[datetime.datetime] = None,
14651466
):
14661467
raise NotImplementedError
14671468

google/cloud/firestore_v1/base_transaction.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"""Helpers for applying Google Cloud Firestore changes in a transaction."""
1616
from __future__ import annotations
1717

18-
from datetime import datetime
18+
import datetime
19+
1920
from typing import (
2021
TYPE_CHECKING,
2122
Any,
@@ -150,7 +151,7 @@ def get_all(
150151
retry: retries.Retry | retries.AsyncRetry | object | None = None,
151152
timeout: float | None = None,
152153
*,
153-
read_time: Optional[datetime] = None,
154+
read_time: Optional[datetime.datetime] = None,
154155
) -> (
155156
Generator[DocumentSnapshot, Any, None]
156157
| Coroutine[Any, Any, AsyncGenerator[DocumentSnapshot, Any]]
@@ -164,7 +165,7 @@ def get(
164165
timeout: float | None = None,
165166
*,
166167
explain_options: Optional[ExplainOptions] = None,
167-
read_time: Optional[datetime] = None,
168+
read_time: Optional[datetime.datetime] = None,
168169
) -> (
169170
StreamGenerator[DocumentSnapshot]
170171
| Generator[DocumentSnapshot, Any, None]

0 commit comments

Comments
 (0)