mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-25 21:39:26 -05:00
Fix type errors introduced by new annotations in the Prometheus Client library. (#11832)
Co-authored-by: David Robertson <davidr@element.io>
This commit is contained in:
parent
dd7f825118
commit
41818cda1f
1
changelog.d/11832.misc
Normal file
1
changelog.d/11832.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix type errors introduced by new annotations in the Prometheus Client library.
|
@ -30,6 +30,7 @@ from typing import (
|
|||||||
Type,
|
Type,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
|
cast,
|
||||||
)
|
)
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
@ -60,7 +61,7 @@ all_gauges: "Dict[str, Union[LaterGauge, InFlightGauge]]" = {}
|
|||||||
HAVE_PROC_SELF_STAT = os.path.exists("/proc/self/stat")
|
HAVE_PROC_SELF_STAT = os.path.exists("/proc/self/stat")
|
||||||
|
|
||||||
|
|
||||||
class RegistryProxy:
|
class _RegistryProxy:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def collect() -> Iterable[Metric]:
|
def collect() -> Iterable[Metric]:
|
||||||
for metric in REGISTRY.collect():
|
for metric in REGISTRY.collect():
|
||||||
@ -68,6 +69,13 @@ class RegistryProxy:
|
|||||||
yield metric
|
yield metric
|
||||||
|
|
||||||
|
|
||||||
|
# A little bit nasty, but collect() above is static so a Protocol doesn't work.
|
||||||
|
# _RegistryProxy matches the signature of a CollectorRegistry instance enough
|
||||||
|
# for it to be usable in the contexts in which we use it.
|
||||||
|
# TODO Do something nicer about this.
|
||||||
|
RegistryProxy = cast(CollectorRegistry, _RegistryProxy)
|
||||||
|
|
||||||
|
|
||||||
@attr.s(slots=True, hash=True, auto_attribs=True)
|
@attr.s(slots=True, hash=True, auto_attribs=True)
|
||||||
class LaterGauge:
|
class LaterGauge:
|
||||||
|
|
||||||
|
@ -76,8 +76,7 @@ REQUIREMENTS = [
|
|||||||
"msgpack>=0.5.2",
|
"msgpack>=0.5.2",
|
||||||
"phonenumbers>=8.2.0",
|
"phonenumbers>=8.2.0",
|
||||||
# we use GaugeHistogramMetric, which was added in prom-client 0.4.0.
|
# we use GaugeHistogramMetric, which was added in prom-client 0.4.0.
|
||||||
# 0.13.0 has an incorrect type annotation, see #11832.
|
"prometheus_client>=0.4.0",
|
||||||
"prometheus_client>=0.4.0,<0.13.0",
|
|
||||||
# we use `order`, which arrived in attrs 19.2.0.
|
# we use `order`, which arrived in attrs 19.2.0.
|
||||||
# Note: 21.1.0 broke `/sync`, see #9936
|
# Note: 21.1.0 broke `/sync`, see #9936
|
||||||
"attrs>=19.2.0,!=21.1.0",
|
"attrs>=19.2.0,!=21.1.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user