Update type annotations for compatiblity with prometheus_client 0.14 (#12389)

Principally, `prometheus_client.REGISTRY.register` now requires its argument to
extend `prometheus_client.Collector`.

Additionally, `Gauge.set` is now annotated so that passing `Optional[int]`
causes an error.
This commit is contained in:
Richard van der Hoff 2022-04-06 13:59:04 +01:00 committed by GitHub
parent 793d03e2c5
commit ae01a7edd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 18 deletions

View file

@ -21,6 +21,8 @@ from prometheus_client.core import REGISTRY, GaugeMetricFamily
from twisted.internet import reactor
from synapse.metrics._types import Collector
#
# Twisted reactor metrics
#
@ -54,7 +56,7 @@ class EpollWrapper:
return getattr(self._poller, item)
class ReactorLastSeenMetric:
class ReactorLastSeenMetric(Collector):
def __init__(self, epoll_wrapper: EpollWrapper):
self._epoll_wrapper = epoll_wrapper