Hacking: Fix E741
E741 ambiguous variable name 'l' Also fix other problems found by hacking in files touched. Change-Id: I8171994716092ae7f12018861e95ed52fee57b18
This commit is contained in:
parent
8098045f2a
commit
3be50ced7a
@ -82,13 +82,13 @@ def _conf2json(conf):
|
||||
|
||||
for pat, s in [
|
||||
# add omitted "=" signs to block openings
|
||||
('([^=\s])\s*{', '\\1={'),
|
||||
(r'([^=\s])\s*{', '\\1={'),
|
||||
# delete trailing semicolons in blocks
|
||||
(';\s*}', '}'),
|
||||
(r';\s*}', '}'),
|
||||
# add omitted semicolons after blocks
|
||||
('}\s*([^}\s])', '};\\1'),
|
||||
(r'}\s*([^}\s])', '};\\1'),
|
||||
# separate syntactically significant characters
|
||||
('([;{}=])', ' \\1 ')]:
|
||||
(r'([;{}=])', ' \\1 ')]:
|
||||
tok = re.sub(pat, s, tok)
|
||||
|
||||
# map tokens to JSON equivalents
|
||||
@ -98,7 +98,7 @@ def _conf2json(conf):
|
||||
elif word == ";":
|
||||
word = ','
|
||||
elif (word in ['{', '}'] or
|
||||
re.search('\A-?[1-9]\d*(\.\d+)?\Z', word)):
|
||||
re.search(r'\A-?[1-9]\d*(\.\d+)?\Z', word)):
|
||||
pass
|
||||
else:
|
||||
word = jsonutils.dumps(word)
|
||||
@ -193,8 +193,8 @@ def parseconf(conf):
|
||||
# occurrences of a config block to be later converted to a
|
||||
# dict key-value pair, with block name being the key and a
|
||||
# list of block contents being the value.
|
||||
l = jsonutils.loads(_conf2json(conf), object_pairs_hook=lambda x: x)
|
||||
d = list_to_dict(l)
|
||||
li = jsonutils.loads(_conf2json(conf), object_pairs_hook=lambda x: x)
|
||||
d = list_to_dict(li)
|
||||
return d
|
||||
|
||||
|
||||
@ -222,7 +222,7 @@ class GaneshaManager(object):
|
||||
"""Ganesha instrumentation class."""
|
||||
|
||||
def __init__(self, execute, tag, **kwargs):
|
||||
self.confrx = re.compile('\.conf\Z')
|
||||
self.confrx = re.compile(r'\.conf\Z')
|
||||
self.ganesha_config_path = kwargs['ganesha_config_path']
|
||||
self.tag = tag
|
||||
|
||||
@ -566,7 +566,7 @@ class GaneshaManager(object):
|
||||
"sqlite3", self.ganesha_db_path,
|
||||
bumpcode + 'select * from ganesha where key = "exportid";',
|
||||
run_as_root=False)[0]
|
||||
match = re.search('\Aexportid\|(\d+)$', out)
|
||||
match = re.search(r'\Aexportid\|(\d+)$', out)
|
||||
if not match:
|
||||
LOG.error("Invalid export database on "
|
||||
"Ganesha node %(tag)s: %(db)s.",
|
||||
|
@ -364,36 +364,37 @@ class ParseLimitsTest(BaseLimitTestSuite):
|
||||
def test_multiple_rules(self):
|
||||
"""Test that parse_limits() handles multiple rules correctly."""
|
||||
try:
|
||||
l = limits.Limiter.parse_limits('(get, *, .*, 20, minute);'
|
||||
'(PUT, /foo*, /foo.*, 10, hour);'
|
||||
'(POST, /bar*, /bar.*, 5, second);'
|
||||
'(Say, /derp*, /derp.*, 1, day)')
|
||||
lim = limits.Limiter.parse_limits(
|
||||
'(get, *, .*, 20, minute);'
|
||||
'(PUT, /foo*, /foo.*, 10, hour);'
|
||||
'(POST, /bar*, /bar.*, 5, second);'
|
||||
'(Say, /derp*, /derp.*, 1, day)')
|
||||
except ValueError as e:
|
||||
assert False, six.text_type(e)
|
||||
|
||||
# Make sure the number of returned limits are correct
|
||||
self.assertEqual(4, len(l))
|
||||
self.assertEqual(4, len(lim))
|
||||
|
||||
# Check all the verbs...
|
||||
expected = ['GET', 'PUT', 'POST', 'SAY']
|
||||
self.assertEqual(expected, [t.verb for t in l])
|
||||
self.assertEqual(expected, [t.verb for t in lim])
|
||||
|
||||
# ...the URIs...
|
||||
expected = ['*', '/foo*', '/bar*', '/derp*']
|
||||
self.assertEqual(expected, [t.uri for t in l])
|
||||
self.assertEqual(expected, [t.uri for t in lim])
|
||||
|
||||
# ...the regexes...
|
||||
expected = ['.*', '/foo.*', '/bar.*', '/derp.*']
|
||||
self.assertEqual(expected, [t.regex for t in l])
|
||||
self.assertEqual(expected, [t.regex for t in lim])
|
||||
|
||||
# ...the values...
|
||||
expected = [20, 10, 5, 1]
|
||||
self.assertEqual(expected, [t.value for t in l])
|
||||
self.assertEqual(expected, [t.value for t in lim])
|
||||
|
||||
# ...and the units...
|
||||
expected = [limits.PER_MINUTE, limits.PER_HOUR,
|
||||
limits.PER_SECOND, limits.PER_DAY]
|
||||
self.assertEqual(expected, [t.unit for t in l])
|
||||
self.assertEqual(expected, [t.unit for t in lim])
|
||||
|
||||
|
||||
class LimiterTest(BaseLimitTestSuite):
|
||||
|
@ -137,13 +137,13 @@ class NetAppApiElementTransTests(test.TestCase):
|
||||
root['l'] = ['l1', 'l2']
|
||||
root['t'] = ('t1', 't2')
|
||||
|
||||
l = root.get_child_by_name('l')
|
||||
self.assertIsInstance(l, api.NaElement)
|
||||
li = root.get_child_by_name('l')
|
||||
self.assertIsInstance(li, api.NaElement)
|
||||
t = root.get_child_by_name('t')
|
||||
self.assertIsInstance(t, api.NaElement)
|
||||
|
||||
self.assertEqual(2, len(l.get_children()))
|
||||
for le in l.get_children():
|
||||
self.assertEqual(2, len(li.get_children()))
|
||||
for le in li.get_children():
|
||||
self.assertIn(le.get_name(), ['l1', 'l2'])
|
||||
|
||||
self.assertEqual(2, len(t.get_children()))
|
||||
|
3
tox.ini
3
tox.ini
@ -134,9 +134,8 @@ commands = alembic -c manila/db/migrations/alembic.ini revision -m ""{posargs}
|
||||
# W503 line break before binary operator
|
||||
# W504 line break after binary operator
|
||||
# W605 invalid escape sequence
|
||||
# E741 ambiguous variable name 'l'
|
||||
# E731 do not assign a lambda expression, use a def
|
||||
ignore = E123,E402,E731,E741,W503,W504,W605
|
||||
ignore = E123,E402,E731,W503,W504,W605
|
||||
builtins = _
|
||||
# [H106] Don't put vim configuration in source files.
|
||||
# [H203] Use assertIs(Not)None to check for None.
|
||||
|
Loading…
x
Reference in New Issue
Block a user