Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add most missing type hints to synapse.util #11328

Merged
merged 14 commits into from
Nov 16, 2021
8 changes: 7 additions & 1 deletion synapse/util/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
sub_metrics=["real_time_max", "real_time_sum"],
)

# This is dynamically created in InFlightGauge.__init__.
clokep marked this conversation as resolved.
Show resolved Hide resolved
class _InFlightMetric(Protocol):
real_time_max: float
real_time_sum: float


T = TypeVar("T", bound=Callable[..., Any])


Expand Down Expand Up @@ -180,7 +186,7 @@ def get_resource_usage(self) -> ContextResourceUsage:
"""
return self._logging_context.get_resource_usage()

def _update_in_flight(self, metrics) -> None:
def _update_in_flight(self, metrics: _InFlightMetric) -> None:
"""Gets called when processing in flight metrics"""
assert self.start is not None
duration = self.clock.time() - self.start
Expand Down