Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 10 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Python StatsD documentation build configuration file, created by
# sphinx-quickstart on Mon Apr 9 15:47:23 2012.
#
Expand All @@ -11,7 +9,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -40,8 +39,8 @@
master_doc = 'index'

# General information about the project.
project = u'Python StatsD'
copyright = u'2015, James Socol'
project = 'Python StatsD'
copyright = '2015, James Socol'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -183,8 +182,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'PythonStatsD.tex', u'Python StatsD Documentation',
u'James Socol', 'manual'),
('index', 'PythonStatsD.tex', 'Python StatsD Documentation',
'James Socol', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -213,8 +212,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pythonstatsd', u'Python StatsD Documentation',
[u'James Socol'], 1)
('index', 'pythonstatsd', 'Python StatsD Documentation',
['James Socol'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -227,8 +226,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'PythonStatsD', u'Python StatsD Documentation',
u'James Socol', 'PythonStatsD', 'One line description of project.',
('index', 'PythonStatsD', 'Python StatsD Documentation',
'James Socol', 'PythonStatsD', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
10 changes: 5 additions & 5 deletions statsd/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .timer import Timer


class StatsClientBase(object):
class StatsClientBase:
"""A Base class for various statsd clients."""

def close(self):
Expand Down Expand Up @@ -51,7 +51,7 @@ def gauge(self, stat, value, rate=1, delta=False):
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."""
Expand All @@ -64,12 +64,12 @@ def _prepare(self, stat, value, rate):
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:
Expand Down
2 changes: 1 addition & 1 deletion statsd/client/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions statsd/client/udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Pipeline(PipelineBase):

def __init__(self, client):
super(Pipeline, self).__init__(client)
super().__init__(client)
self._maxudpsize = client._maxudpsize

def _send(self):
Expand Down Expand Up @@ -40,7 +40,7 @@ def _send(self, data):
"""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

Expand Down
6 changes: 3 additions & 3 deletions statsd/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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):
Expand Down Expand Up @@ -132,7 +132,7 @@ def __enter__(self):

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
Expand Down