diff options
Diffstat (limited to 'statsd')
-rw-r--r-- | statsd/client/base.py | 10 | ||||
-rw-r--r-- | statsd/client/timer.py | 2 | ||||
-rw-r--r-- | statsd/client/udp.py | 4 | ||||
-rw-r--r-- | statsd/tests.py | 6 |
4 files changed, 11 insertions, 11 deletions
diff --git a/statsd/client/base.py b/statsd/client/base.py index 61dcf18..4fbbe5c 100644 --- a/statsd/client/base.py +++ b/statsd/client/base.py @@ -5,7 +5,7 @@ from datetime import timedelta from .timer import Timer -class StatsClientBase(object): +class StatsClientBase: """A Base class for various statsd clients.""" def close(self): @@ -51,7 +51,7 @@ class StatsClientBase(object): pipe._send_stat(stat, '%s|g' % value, 1) else: prefix = '+' if delta and value >= 0 else '' - self._send_stat(stat, '%s%s|g' % (prefix, value), rate) + self._send_stat(stat, '{}{}|g'.format(prefix, value), rate) def set(self, stat, value, rate=1): """Set a set value.""" @@ -64,12 +64,12 @@ class StatsClientBase(object): if rate < 1: if random.random() > rate: return - value = '%s|@%s' % (value, rate) + value = '{}|@{}'.format(value, rate) if self._prefix: - stat = '%s.%s' % (self._prefix, stat) + stat = '{}.{}'.format(self._prefix, stat) - return '%s:%s' % (stat, value) + return '{}:{}'.format(stat, value) def _after(self, data): if data: diff --git a/statsd/client/timer.py b/statsd/client/timer.py index 453197e..5354a47 100644 --- a/statsd/client/timer.py +++ b/statsd/client/timer.py @@ -10,7 +10,7 @@ def safe_wraps(wrapper, *args, **kwargs): return functools.wraps(wrapper, *args, **kwargs) -class Timer(object): +class Timer: """A context manager/decorator for statsd.timing().""" def __init__(self, client, stat, rate=1): diff --git a/statsd/client/udp.py b/statsd/client/udp.py index 4e44d5c..ec10fc7 100644 --- a/statsd/client/udp.py +++ b/statsd/client/udp.py @@ -6,7 +6,7 @@ from .base import StatsClientBase, PipelineBase class Pipeline(PipelineBase): def __init__(self, client): - super(Pipeline, self).__init__(client) + super().__init__(client) self._maxudpsize = client._maxudpsize def _send(self): @@ -40,7 +40,7 @@ class StatsClient(StatsClientBase): """Send data to statsd.""" try: self._sock.sendto(data.encode('ascii'), self._addr) - except (socket.error, RuntimeError): + except (OSError, RuntimeError): # No time for love, Dr. Jones! pass diff --git a/statsd/tests.py b/statsd/tests.py index d1b2a96..5688977 100644 --- a/statsd/tests.py +++ b/statsd/tests.py @@ -69,7 +69,7 @@ def _timer_check(sock, count, proto, start, end): send = send_method[proto](sock) eq_(send.call_count, count) value = send.call_args[0][0].decode('ascii') - exp = re.compile(r'^%s:\d+|%s$' % (start, end)) + exp = re.compile(r'^{}:\d+|{}$'.format(start, end)) assert exp.match(value) @@ -85,7 +85,7 @@ def _sock_check(sock, count, proto, val=None, addr=None): ) -class assert_raises(object): +class assert_raises: """A context manager that asserts a given exception was raised. >>> with assert_raises(TypeError): @@ -132,7 +132,7 @@ class assert_raises(object): def __exit__(self, typ, value, tb): assert typ, 'No exception raised.' - assert typ in self.exc_cls, '%s not in %s' % ( + assert typ in self.exc_cls, '{} not in {}'.format( typ.__name__, [e.__name__ for e in self.exc_cls]) self.exc_type = typ self.exception = value |