Skip to content

Commit 263cab9

Browse files
jahodfrasgnn7
andauthored
Add more type annotations to dogstatsd (#710)
Add type hints to statsd decrement, histogram, distribution, and timing functions to be able to use mypy integration better. Co-authored-by: Srdjan Grubor <[email protected]>
1 parent 5533f88 commit 263cab9

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

datadog/dogstatsd/base.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,13 @@ def increment(
570570
"""
571571
self._report(metric, "c", value, tags, sample_rate)
572572

573-
def decrement(self, metric, value=1, tags=None, sample_rate=None):
573+
def decrement(
574+
self,
575+
metric, # type: Text
576+
value=1, # type: float
577+
tags=None, # type: Optional[List[str]]
578+
sample_rate=None, # type: Optional[float]
579+
): # type(...) -> None
574580
"""
575581
Decrement a counter, optionally setting a value, tags and a sample
576582
rate.
@@ -581,7 +587,13 @@ def decrement(self, metric, value=1, tags=None, sample_rate=None):
581587
metric_value = -value if value else value
582588
self._report(metric, "c", metric_value, tags, sample_rate)
583589

584-
def histogram(self, metric, value, tags=None, sample_rate=None):
590+
def histogram(
591+
self,
592+
metric, # type: Text
593+
value, # type: float
594+
tags=None, # type: Optional[List[str]]
595+
sample_rate=None, # type: Optional[float]
596+
): # type(...) -> None
585597
"""
586598
Sample a histogram value, optionally setting tags and a sample rate.
587599
@@ -590,7 +602,13 @@ def histogram(self, metric, value, tags=None, sample_rate=None):
590602
"""
591603
self._report(metric, "h", value, tags, sample_rate)
592604

593-
def distribution(self, metric, value, tags=None, sample_rate=None):
605+
def distribution(
606+
self,
607+
metric, # type: Text
608+
value, # type: float
609+
tags=None, # type: Optional[List[str]]
610+
sample_rate=None, # type: Optional[float]
611+
): # type(...) -> None
594612
"""
595613
Send a global distribution value, optionally setting tags and a sample rate.
596614
@@ -599,7 +617,13 @@ def distribution(self, metric, value, tags=None, sample_rate=None):
599617
"""
600618
self._report(metric, "d", value, tags, sample_rate)
601619

602-
def timing(self, metric, value, tags=None, sample_rate=None):
620+
def timing(
621+
self,
622+
metric, # type: Text
623+
value, # type: float
624+
tags=None, # type: Optional[List[str]]
625+
sample_rate=None, # type: Optional[float]
626+
): # type(...) -> None
603627
"""
604628
Record a timing, optionally setting tags and a sample rate.
605629

0 commit comments

Comments
 (0)