8000 Fix lint for line continuation indents (#242) · sonlinux/client_python@fd334b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit fd334b8

Browse files
bz2brian-brazil
authored andcommitted
Fix lint for line continuation indents (prometheus#242)
Resolves E126, E127, and E128. Drive-by slight improvement to CollectorRegistry error raising by including all duplicated names in the message.
1 parent 55eab1f commit fd334b8

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

prometheus_client/core.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ def register(self, collector):
4848
'''Add a collector to the registry.'''
4949
with self._lock:
5050
names = self._get_names(collector)
51-
for name in names:
52-
if name in self._names_to_collectors:
53-
raise ValueError('Timeseries already present '
54-
'in CollectorRegistry: ' + name)
51+
duplicates = set(self._names_to_collectors).intersection(names)
52+
if duplicates:
53+
raise ValueError(
54+
'Duplicated timeseries in CollectorRegistry: {}'.format(
55+
duplicates))
5556
for name in names:
5657
self._names_to_collectors[name] = collector
5758
self._collector_to_names[collector] = names
@@ -444,7 +445,8 @@ def __reset(self):
444445
file_prefix = typ
445446
if file_prefix not in files:
446447
filename = os.path.join(
447-
os.environ['prometheus_multiproc_dir'], '{0}_{1}.db'.format(file_prefix, pid['value']))
448+
os.environ['prometheus_multiproc_dir'],
449+
'{0}_{1}.db'.format(file_prefix, pid['value']))
448450
files[file_prefix] = _MmapedDict(filename)
449451
self._file = files[file_prefix]
450452
self._key = json.dumps((metric_name, name, labelnames, labelvalues))
@@ -710,8 +712,9 @@ def __init__(self, name, labelnames, labelvalues, multiprocess_mode='all'):
710712
if (_ValueClass._multiprocess
711713
and multiprocess_mode not in ['min', 'max', 'livesum', 'liveall', 'all']):
712714
raise ValueError('Invalid multiprocess mode: ' + multiprocess_mode)
713-
self._value = _ValueClass(self._type, name, name, labelnames,
714-
labelvalues, multiprocess_mode=multiprocess_mode)
715+
self._value = _ValueClass(
716+
self._type, name, name, labelnames, labelvalues,
717+
multiprocess_mode=multiprocess_mode)
715718

716719
def inc(self, amount=1):
717720
'''Increment gauge by the given amount.'''

prometheus_client/exposition.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ def _use_gateway(method, gateway, job, registry, grouping_key, timeout, handler)
286286

287287
if grouping_key is None:
288288
grouping_key = {}
289-
url = url + ''.join(['/{0}/{1}'.format(quote_plus(str(k)), quote_plus(str(v)))
290-
for k, v in sorted(grouping_key.items())])
289+
url += ''.join(
290+
'/{0}/{1}'.format(quote_plus(str(k)), quote_plus(str(v)))
291+
for k, v in sorted(grouping_key.items()))
291292

292293
headers=[('Content-Type', CONTENT_TYPE_LATEST)]
293294
handler(url=url, method=method, timeout=timeout,

tests/test_multiprocess.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ def test_multi_expansion(self):
153153
self.d.write_value('abc', 42.0)
154154
self.d.write_value(key, 123.0)
155155
self.d.write_value('def', 17.0)
156-
self.assertEqual([('abc', 42.0), (key B001 , 123.0), ('def', 17.0)],
157-
list(self.d.read_all_values()))
156+
self.assertEqual(
157+
[('abc', 42.0), (key, 123.0), ('def', 17.0)],
158+
list(self.d.read_all_values()))
158159

159160
def tearDown(self):
160161
os.unlink(self.tempfile)

tox.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ ignore =
6161
D,
6262
I,
6363
E123,
64-
E126,
65-
E127,
66-
E128,
6764
E231,
6865
E222,
6966
E225,

0 commit comments

Comments
 (0)
0