Skip to content

Commit

Permalink
Add more type annotations to dogstatsd (#710)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jahodfra and sgnn7 authored Feb 2, 2022
1 parent 5533f88 commit 263cab9
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,13 @@ def increment(
"""
self._report(metric, "c", value, tags, sample_rate)

def decrement(self, metric, value=1, tags=None, sample_rate=None):
def decrement(
self,
metric, # type: Text
value=1, # type: float
tags=None, # type: Optional[List[str]]
sample_rate=None, # type: Optional[float]
): # type(...) -> None
"""
Decrement a counter, optionally setting a value, tags and a sample
rate.
Expand All @@ -581,7 +587,13 @@ def decrement(self, metric, value=1, tags=None, sample_rate=None):
metric_value = -value if value else value
self._report(metric, "c", metric_value, tags, sample_rate)

def histogram(self, metric, value, tags=None, sample_rate=None):
def histogram(
self,
metric, # type: Text
value, # type: float
tags=None, # type: Optional[List[str]]
sample_rate=None, # type: Optional[float]
): # type(...) -> None
"""
Sample a histogram value, optionally setting tags and a sample rate.
Expand All @@ -590,7 +602,13 @@ def histogram(self, metric, value, tags=None, sample_rate=None):
"""
self._report(metric, "h", value, tags, sample_rate)

def distribution(self, metric, value, tags=None, sample_rate=None):
def distribution(
self,
metric, # type: Text
value, # type: float
tags=None, # type: Optional[List[str]]
sample_rate=None, # type: Optional[float]
): # type(...) -> None
"""
Send a global distribution value, optionally setting tags and a sample rate.
Expand All @@ -599,7 +617,13 @@ def distribution(self, metric, value, tags=None, sample_rate=None):
"""
self._report(metric, "d", value, tags, sample_rate)

def timing(self, metric, value, tags=None, sample_rate=None):
def timing(
self,
metric, # type: Text
value, # type: float
tags=None, # type: Optional[List[str]]
sample_rate=None, # type: Optional[float]
): # type(...) -> None
"""
Record a timing, optionally setting tags and a sample rate.
Expand Down

0 comments on commit 263cab9

Please sign in to comment.