Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions sdks/python/apache_beam/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def __init__(self, data_class):
def reset(self):
self.data = self.data_class.identity_element()

def combine(self, other: 'AbstractMetricCell') -> 'AbstractMetricCell':
def combine(self, other: AbstractMetricCell) -> AbstractMetricCell:
result = type(self)() # type: ignore[call-arg]
result.data = self.data.combine(other.data)
return result
Expand Down Expand Up @@ -670,7 +670,7 @@ class _BoundedTrieNode(object):
def __init__(self):
# invariant: size = len(self.flattened()) = min(1, sum(size of children))
self._size = 1
self._children: Optional[dict[str, '_BoundedTrieNode']] = {}
self._children: Optional[dict[str, _BoundedTrieNode]] = {}
self._truncated = False

def to_proto(self) -> metrics_pb2.BoundedTrieNode:
Expand All @@ -682,7 +682,7 @@ def to_proto(self) -> metrics_pb2.BoundedTrieNode:
} if self._children else None)

@staticmethod
def from_proto(proto: metrics_pb2.BoundedTrieNode) -> '_BoundedTrieNode':
def from_proto(proto: metrics_pb2.BoundedTrieNode) -> _BoundedTrieNode:
node = _BoundedTrieNode()
if proto.truncated:
node._truncated = True
Expand Down Expand Up @@ -736,7 +736,7 @@ def trim(self) -> int:
self._size += delta
return delta

def merge(self, other: '_BoundedTrieNode') -> int:
def merge(self, other: _BoundedTrieNode) -> int:
if self._truncated:
delta = 0
elif other._truncated:
Expand All @@ -750,8 +750,8 @@ def merge(self, other: '_BoundedTrieNode') -> int:
delta = other._size - self._size
else:
delta = 0
other_child: '_BoundedTrieNode'
self_child: Optional['_BoundedTrieNode']
other_child: _BoundedTrieNode
self_child: Optional[_BoundedTrieNode]
for prefix, other_child in other._children.items():
self_child = self._children.get(prefix, None)
if self_child is None:
Expand Down Expand Up @@ -822,7 +822,7 @@ def to_proto(self) -> metrics_pb2.BoundedTrie:
root=self._root.to_proto() if self._root else None)

@staticmethod
def from_proto(proto: metrics_pb2.BoundedTrie) -> 'BoundedTrieData':
def from_proto(proto: metrics_pb2.BoundedTrie) -> BoundedTrieData:
return BoundedTrieData(
bound=proto.bound,
singleton=tuple(proto.singleton) if proto.singleton else None,
Expand Down Expand Up @@ -851,7 +851,7 @@ def __hash__(self) -> int:
def __repr__(self) -> str:
return 'BoundedTrieData({})'.format(self.as_trie())

def get_cumulative(self) -> "BoundedTrieData":
def get_cumulative(self) -> BoundedTrieData:
return copy.deepcopy(self)

def get_result(self) -> Set[tuple]:
Expand All @@ -877,7 +877,7 @@ def add(self, segments):
if self._root._size > self._bound:
self._root.trim()

def combine(self, other: "BoundedTrieData") -> "BoundedTrieData":
def combine(self, other: BoundedTrieData) -> BoundedTrieData:
if self._root is None and self._singleton is None:
return other
elif other._root is None and other._singleton is None:
Expand All @@ -896,13 +896,13 @@ def combine(self, other: "BoundedTrieData") -> "BoundedTrieData":
return BoundedTrieData(root=combined)

@staticmethod
def singleton(value: str) -> "BoundedTrieData":
def singleton(value: str) -> BoundedTrieData:
s = BoundedTrieData()
s.add(value)
return s

@staticmethod
def identity_element() -> "BoundedTrieData":
def identity_element() -> BoundedTrieData:
return BoundedTrieData()


Expand Down
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/utils/windowed_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def __hash__(self):

@staticmethod
def from_batch_and_windowed_value(
*, batch, windowed_value: WindowedValue) -> 'WindowedBatch':
*, batch, windowed_value: WindowedValue) -> WindowedBatch:
return HomogeneousWindowedBatch(windowed_value.with_value(batch))

@staticmethod
Expand Down
Loading