Skip to content

Commit

Permalink
Type hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertwb committed Nov 25, 2024
1 parent aa939c1 commit 58e48fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/internal/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ def combine(self, other: Optional['HistogramData']) -> 'HistogramData':
return HistogramData(self.histogram.combine(other.histogram))

@staticmethod
def identity_element(bucket_type) -> HistogramData:
def identity_element(bucket_type) -> 'HistogramData':
return HistogramData(Histogram(bucket_type))
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/metrics/cells.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cdef class DistributionCell(MetricCell):

cdef class AbstractMetricCell(MetricCell):
cdef readonly object data_class
cdef readonly object data
cdef public object data
cdef bint _update_locked(self, value) except -1


Expand Down
6 changes: 2 additions & 4 deletions sdks/python/apache_beam/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
import threading
import time
from datetime import datetime
from typing import Any
from typing import Iterable
from typing import Optional
from typing import Set
from typing import SupportsInt

try:
import cython
Expand Down Expand Up @@ -233,7 +231,7 @@ def reset(self):
self.data = self.data_class.identity_element()

def combine(self, other: 'AbstractMetricCell') -> 'AbstractMetricCell':
result = type(self)()
result = type(self)() # type: ignore[call-arg]
result.data = self.data.combine(other.data)
return result

Expand Down Expand Up @@ -506,7 +504,7 @@ def get_cumulative(self):
# type: () -> DistributionData
return DistributionData(self.sum, self.count, self.min, self.max)

def get_result(self):
def get_result(self) -> DistributionResult:
return DistributionResult(self.get_cumulative())

def combine(self, other):
Expand Down
2 changes: 1 addition & 1 deletion sdks/python/apache_beam/runners/direct/direct_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self):
self._distributions = defaultdict(
lambda: DirectMetric(GenericAggregator(DistributionData)))
self._gauges = defaultdict(
lambda: DirectMetric(GenericAggregator(GuageData)))
lambda: DirectMetric(GenericAggregator(GaugeData)))
self._string_sets = defaultdict(
lambda: DirectMetric(GenericAggregator(StringSetData)))

Expand Down

0 comments on commit 58e48fc

Please sign in to comment.