Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change labels() method return type #58

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions pytheus/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
import time
from contextlib import contextmanager
from dataclasses import dataclass
from typing import Callable, Dict, Generator, Iterable, Optional, Sequence, Tuple, Type, Union
from typing import (
TYPE_CHECKING,
Callable,
Dict,
Generator,
Iterable,
Optional,
Sequence,
Tuple,
Type,
Union,
)

from pytheus.backends import get_backend
from pytheus.exceptions import (
Expand All @@ -16,6 +27,10 @@
from pytheus.registry import REGISTRY, Collector, Registry
from pytheus.utils import InfFloat, MetricType

# Backwards compatibility for python<3.11
if TYPE_CHECKING:
from typing import Self
pradishb marked this conversation as resolved.
Show resolved Hide resolved

Labels = Dict[str, str]


Expand Down Expand Up @@ -202,7 +217,7 @@ def _raise_if_cannot_observe(self) -> None:
if not self._can_observe:
raise UnobservableMetricException

def labels(self, pytheus_labels_: Optional[Labels] = None, **kwargs: str) -> "_Metric":
def labels(self, pytheus_labels_: Optional[Labels] = None, **kwargs: str) -> "Self":
pradishb marked this conversation as resolved.
Show resolved Hide resolved
"""
If no labels is passed to the call returns itself.
If there are already present labels, they will be updated with the passed labels_ and if
Expand Down