Skip to content

Commit fc0d989

Browse files
authored
Replace non-PEP 585 types in watch.py (#39527)
* Fix legacy typing.Tuple usage in watch.py * Swap to the correct iterable
1 parent 55fde07 commit fc0d989

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

sdks/python/apache_beam/io/watch.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ def poll(prefix) -> PollResult[str]:
5959
import inspect
6060
import time
6161
import typing
62+
from collections.abc import Iterable
6263
from typing import Any
6364
from typing import Callable
6465
from typing import Generic
65-
from typing import Iterable
6666
from typing import Optional
67-
from typing import Tuple
6867
from typing import TypeVar
6968

7069
from apache_beam import coders
@@ -111,15 +110,15 @@ class PollResult(Generic[OutputT]):
111110
The ``OutputT`` type parameter can annotate a poll function's return type,
112111
as in ``-> PollResult[str]``; the transform infers the output coder from it.
113112
"""
114-
outputs: Tuple[TimestampedValue, ...]
113+
outputs: tuple[TimestampedValue, ...]
115114
watermark: Optional[Timestamp] = None
116115

117116
@property
118117
def is_complete(self) -> bool:
119118
return self.watermark == MAX_TIMESTAMP
120119

121120
@staticmethod
122-
def _normalize(outputs, timestamp) -> Tuple[TimestampedValue, ...]:
121+
def _normalize(outputs, timestamp) -> tuple[TimestampedValue, ...]:
123122
if timestamp is None:
124123
default_ts = Timestamp.now()
125124
else:
@@ -428,7 +427,7 @@ def _hash(self, value: Any) -> bytes:
428427
def current_restriction(self) -> _GrowthState:
429428
return self._restriction
430429

431-
def try_claim(self, position: Tuple[PollResult, Any]) -> bool:
430+
def try_claim(self, position: tuple[PollResult, Any]) -> bool:
432431
"""Claims one poll round; at most one claim succeeds per ``process()``.
433432
434433
The claim is rejected after a checkpoint already stopped this invocation,
@@ -723,7 +722,7 @@ def expand(self, pcoll):
723722
output_coder,
724723
key_fn,
725724
key_coder,
726-
self._now)).with_output_types(Tuple[input_type, value_type])
725+
self._now)).with_output_types(tuple[input_type, value_type])
727726

728727

729728
def _as_duration(value) -> Duration:

0 commit comments

Comments
 (0)