Skip to content

Commit 344d9f7

Browse files
committed
make Sample namedtuple use Dict instead of Mapping
1 parent 098b758 commit 344d9f7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

prometheus_client/metrics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ def _multi_samples(self):
218218
for suffix, sample_labels, value, timestamp, exemplar in metric._samples():
219219
yield (suffix, dict(series_labels + list(sample_labels.items())), value, timestamp, exemplar)
220220

221-
def _child_samples(self): # pragma: no cover
222-
# type: () -> Sequence[Tuple[str, Dict[str, str], float]]
221+
def _child_samples(self) -> Sequence[Tuple[str, Dict[str, str], float]]: # pragma: no cover
223222
raise NotImplementedError('_child_samples() must be implemented by %r' % self)
224223

225224
def _metric_init(self): # pragma: no cover

prometheus_client/samples.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from collections import namedtuple
2-
from typing import Mapping, NamedTuple, Optional, Sequence
1+
from typing import Dict, NamedTuple, Optional
32

43

54
class Timestamp:
@@ -38,14 +37,14 @@ def __gt__(self, other):
3837
# a Timestamp object, or None.
3938
# Exemplar can be an Exemplar object, or None.
4039
class Exemplar(NamedTuple):
41-
labels: Mapping[str, str]
40+
labels: Dict[str, str]
4241
value: float
4342
timestamp: Optional[float] = None
4443

4544

4645
class Sample(NamedTuple):
4746
name: str
48-
labels: Mapping[str, str]
47+
labels: Dict[str, str]
4948
value: float
5049
timestamp: Optional[float] = None
5150
exemplar: Optional[Exemplar] = None

0 commit comments

Comments
 (0)