Skip to content

Commit 50a9419

Browse files
cclaussjsocol
authored andcommitted
pyupgrade: Modernize syntax for Python >= 3.7
1 parent dc1cb87 commit 50a9419

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

docs/conf.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
#
31
# Python StatsD documentation build configuration file, created by
42
# sphinx-quickstart on Mon Apr 9 15:47:23 2012.
53
#
@@ -11,7 +9,8 @@
119
# All configuration values have a default; values that are commented out
1210
# serve to show the default.
1311

14-
import sys, os
12+
import os
13+
import sys
1514

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

4241
# General information about the project.
43-
project = u'Python StatsD'
44-
copyright = u'2015, James Socol'
42+
project = 'Python StatsD'
43+
copyright = '2015, James Socol'
4544

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

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

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

statsd/client/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .timer import Timer
66

77

8-
class StatsClientBase(object):
8+
class StatsClientBase:
99
"""A Base class for various statsd clients."""
1010

1111
def close(self):
@@ -51,7 +51,7 @@ def gauge(self, stat, value, rate=1, delta=False):
5151
pipe._send_stat(stat, '%s|g' % value, 1)
5252
else:
5353
prefix = '+' if delta and value >= 0 else ''
54-
self._send_stat(stat, '%s%s|g' % (prefix, value), rate)
54+
self._send_stat(stat, '{}{}|g'.format(prefix, value), rate)
5555

5656
def set(self, stat, value, rate=1):
5757
"""Set a set value."""
@@ -64,12 +64,12 @@ def _prepare(self, stat, value, rate):
6464
if rate < 1:
6565
if random.random() > rate:
6666
return
67-
value = '%s|@%s' % (value, rate)
67+
value = '{}|@{}'.format(value, rate)
6868

6969
if self._prefix:
70-
stat = '%s.%s' % (self._prefix, stat)
70+
stat = '{}.{}'.format(self._prefix, stat)
7171

72-
return '%s:%s' % (stat, value)
72+
return '{}:{}'.format(stat, value)
7373

7474
def _after(self, data):
7575
if data:

statsd/client/timer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def safe_wraps(wrapper, *args, **kwargs):
1010
return functools.wraps(wrapper, *args, **kwargs)
1111

1212

13-
class Timer(object):
13+
class Timer:
1414
"""A context manager/decorator for statsd.timing()."""
1515

1616
def __init__(self, client, stat, rate=1):

statsd/client/udp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Pipeline(PipelineBase):
77

88
def __init__(self, client):
9-
super(Pipeline, self).__init__(client)
9+
super().__init__(client)
1010
self._maxudpsize = client._maxudpsize
1111

1212
def _send(self):
@@ -40,7 +40,7 @@ def _send(self, data):
4040
"""Send data to statsd."""
4141
try:
4242
self._sock.sendto(data.encode('ascii'), self._addr)
43-
except (socket.error, RuntimeError):
43+
except (OSError, RuntimeError):
4444
# No time for love, Dr. Jones!
4545
pass
4646

statsd/tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _timer_check(sock, count, proto, start, end):
6969
send = send_method[proto](sock)
7070
eq_(send.call_count, count)
7171
value = send.call_args[0][0].decode('ascii')
72-
exp = re.compile(r'^%s:\d+|%s$' % (start, end))
72+
exp = re.compile(r'^{}:\d+|{}$'.format(start, end))
7373
assert exp.match(value)
7474

7575

@@ -85,7 +85,7 @@ def _sock_check(sock, count, proto, val=None, addr=None):
8585
)
8686

8787

88-
class assert_raises(object):
88+
class assert_raises:
8989
"""A context manager that asserts a given exception was raised.
9090
9191
>>> with assert_raises(TypeError):
@@ -132,7 +132,7 @@ def __enter__(self):
132132

133133
def __exit__(self, typ, value, tb):
134134
assert typ, 'No exception raised.'
135-
assert typ in self.exc_cls, '%s not in %s' % (
135+
assert typ in self.exc_cls, '{} not in {}'.format(
136136
typ.__name__, [e.__name__ for e in self.exc_cls])
137137
self.exc_type = typ
138138
self.exception = value

0 commit comments

Comments
 (0)