Fix pep8 failures
With an updated flake8, we get some new warnings. Update hacking directly to version 3.1.0 and fix the problems found. Note that before this change, flake8 used the default "ignore" list, this now adds a new ignore list. Change-Id: Iccbf4f30eb4e542d3824b7782f43eacda29c5a90
This commit is contained in:
parent
c4c57a1680
commit
1d77244f18
@ -73,9 +73,9 @@ class OSProfilerShell(object):
|
||||
command_parser.set_defaults(func=callback)
|
||||
|
||||
def _no_project_and_domain_set(self, args):
|
||||
if not (args.os_project_id or (args.os_project_name and
|
||||
(args.os_user_domain_name or args.os_user_domain_id)) or
|
||||
(args.os_tenant_id or args.os_tenant_name)):
|
||||
if not (args.os_project_id or (args.os_project_name
|
||||
and (args.os_user_domain_name or args.os_user_domain_id))
|
||||
or (args.os_tenant_id or args.os_tenant_name)):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -228,8 +228,8 @@ class Driver(object):
|
||||
def msec(dt):
|
||||
# NOTE(boris-42): Unfortunately this is the simplest way that works
|
||||
# in py26 and py27
|
||||
microsec = (dt.microseconds + (dt.seconds + dt.days * 24 * 3600) *
|
||||
1e6)
|
||||
microsec = (dt.microseconds + (dt.seconds + dt.days * 24 * 3600)
|
||||
* 1e6)
|
||||
return int(microsec / 1000.0)
|
||||
|
||||
stats = {}
|
||||
@ -245,8 +245,8 @@ class Driver(object):
|
||||
|
||||
op_type = r["info"]["name"]
|
||||
op_started = msec(r["info"]["started"] - self.started_at)
|
||||
op_finished = msec(r["info"]["finished"] -
|
||||
self.started_at)
|
||||
op_finished = msec(r["info"]["finished"]
|
||||
- self.started_at)
|
||||
duration = op_finished - op_started
|
||||
|
||||
r["info"]["started"] = op_started
|
||||
@ -256,7 +256,7 @@ class Driver(object):
|
||||
stats[op_type] = {
|
||||
"count": 1,
|
||||
"duration": duration
|
||||
}
|
||||
}
|
||||
else:
|
||||
stats[op_type]["count"] += 1
|
||||
stats[op_type]["duration"] += duration
|
||||
@ -265,8 +265,9 @@ class Driver(object):
|
||||
"info": {
|
||||
"name": "total",
|
||||
"started": 0,
|
||||
"finished": msec(self.finished_at -
|
||||
self.started_at) if self.started_at else None,
|
||||
"finished": msec(
|
||||
self.finished_at - self.started_at
|
||||
) if self.started_at else None,
|
||||
"last_trace_started": msec(
|
||||
self.last_started_at - self.started_at
|
||||
) if self.started_at else None
|
||||
|
@ -166,8 +166,8 @@ def assert_equal_none(logical_line, filename):
|
||||
|
||||
N322
|
||||
"""
|
||||
res = (re_assert_equal_start_with_none.search(logical_line) or
|
||||
re_assert_equal_end_with_none.search(logical_line))
|
||||
res = (re_assert_equal_start_with_none.search(logical_line)
|
||||
or re_assert_equal_end_with_none.search(logical_line))
|
||||
if res:
|
||||
yield (0, "N322 assertEqual(A, None) or assertEqual(None, A) "
|
||||
"sentences not allowed, you should use assertIsNone(A) "
|
||||
@ -185,8 +185,9 @@ def assert_true_or_false_with_in(logical_line, filename):
|
||||
|
||||
N323
|
||||
"""
|
||||
res = (re_assert_true_false_with_in_or_not_in.search(logical_line) or
|
||||
re_assert_true_false_with_in_or_not_in_spaces.search(logical_line))
|
||||
res = (re_assert_true_false_with_in_or_not_in.search(logical_line)
|
||||
or re_assert_true_false_with_in_or_not_in_spaces.search(
|
||||
logical_line))
|
||||
if res:
|
||||
yield (0, "N323 assertTrue/assertFalse(A in/not in B)sentences not "
|
||||
"allowed, you should use assertIn(A, B) or assertNotIn(A, B)"
|
||||
@ -204,8 +205,8 @@ def assert_equal_in(logical_line, filename):
|
||||
|
||||
N324
|
||||
"""
|
||||
res = (re_assert_equal_in_end_with_true_or_false.search(logical_line) or
|
||||
re_assert_equal_in_start_with_true_or_false.search(logical_line))
|
||||
res = (re_assert_equal_in_end_with_true_or_false.search(logical_line)
|
||||
or re_assert_equal_in_start_with_true_or_false.search(logical_line))
|
||||
if res:
|
||||
yield (0, "N324: Use assertIn/NotIn(A, B) rather than "
|
||||
"assertEqual(A in/not in B, True/False) when checking "
|
||||
@ -226,8 +227,8 @@ def check_quotes(logical_line, filename):
|
||||
|
||||
check_tripple = (
|
||||
lambda line, i, char: (
|
||||
i + 2 < len(line) and
|
||||
(char == line[i] == line[i + 1] == line[i + 2])
|
||||
i + 2 < len(line)
|
||||
and (char == line[i] == line[i + 1] == line[i + 2])
|
||||
)
|
||||
)
|
||||
|
||||
@ -291,9 +292,9 @@ def check_dict_formatting_in_string(logical_line, tokens):
|
||||
# NOTE(stpierre): Can't use @skip_ignored_lines here because it's
|
||||
# a stupid decorator that only works on functions that take
|
||||
# (logical_line, filename) as arguments.
|
||||
if (not logical_line or
|
||||
logical_line.startswith("#") or
|
||||
logical_line.endswith("# noqa")):
|
||||
if (not logical_line
|
||||
or logical_line.startswith("#")
|
||||
or logical_line.endswith("# noqa")):
|
||||
return
|
||||
|
||||
current_string = ""
|
||||
|
@ -306,8 +306,8 @@ class TracedMeta(type):
|
||||
|
||||
traceable_attrs = []
|
||||
for attr_name, attr_value in attrs.items():
|
||||
if not (inspect.ismethod(attr_value) or
|
||||
inspect.isfunction(attr_value)):
|
||||
if not (inspect.ismethod(attr_value)
|
||||
or inspect.isfunction(attr_value)):
|
||||
continue
|
||||
if attr_name.startswith("__"):
|
||||
continue
|
||||
|
@ -293,4 +293,4 @@ class LogInsightClientTestCase(test.TestCase):
|
||||
exp_send_request_call = mock.call(
|
||||
"get", "https", "api/v1/events/foo/CONTAINS+bar/timestamp/GT+0",
|
||||
headers=exp_header, params=exp_params)
|
||||
send_request.assert_has_calls([exp_send_request_call]*2)
|
||||
send_request.assert_has_calls([exp_send_request_call] * 2)
|
||||
|
@ -143,7 +143,7 @@ class MongoDBParserTestCase(test.TestCase):
|
||||
"db": {
|
||||
"params": {
|
||||
|
||||
},
|
||||
},
|
||||
"statement": "SELECT 1"
|
||||
},
|
||||
"service": None
|
||||
@ -305,8 +305,7 @@ class MongoDBParserTestCase(test.TestCase):
|
||||
"finished": 88,
|
||||
"name": "total",
|
||||
"started": 0,
|
||||
"last_trace_started": 88
|
||||
},
|
||||
"last_trace_started": 88},
|
||||
"stats": {"db": {"count": 1, "duration": 20},
|
||||
"wsgi": {"count": 3, "duration": 0}}}
|
||||
|
||||
|
@ -146,7 +146,7 @@ class RedisParserTestCase(test.TestCase):
|
||||
"db": {
|
||||
"params": {
|
||||
|
||||
},
|
||||
},
|
||||
"statement": "SELECT 1"
|
||||
},
|
||||
"service": None
|
||||
@ -195,8 +195,8 @@ class RedisParserTestCase(test.TestCase):
|
||||
"parent_id": "7253ca8c-33b3-4f84-b4f1-f5a4311ddfa4",
|
||||
"base_id": "7253ca8c-33b3-4f84-b4f1-f5a4311ddfa4"
|
||||
}]
|
||||
results = {result["base_id"] + "_" + result["trace_id"] +
|
||||
"_" + result["timestamp"]: result
|
||||
results = {result["base_id"] + "_" + result["trace_id"]
|
||||
+ "_" + result["timestamp"]: result
|
||||
for result in result_elements}
|
||||
|
||||
expected = {"children": [{"children": [{
|
||||
@ -311,8 +311,7 @@ class RedisParserTestCase(test.TestCase):
|
||||
"finished": 88,
|
||||
"name": "total",
|
||||
"started": 0,
|
||||
"last_trace_started": 88
|
||||
},
|
||||
"last_trace_started": 88},
|
||||
"stats": {"db": {"count": 1, "duration": 20},
|
||||
"wsgi": {"count": 3, "duration": 0}}}
|
||||
|
||||
|
@ -107,8 +107,8 @@ class WsgiMiddleware(object):
|
||||
|
||||
@webob.dec.wsgify
|
||||
def __call__(self, request):
|
||||
if (_ENABLED is not None and not _ENABLED or
|
||||
_ENABLED is None and not self.enabled):
|
||||
if (_ENABLED is not None and not _ENABLED
|
||||
or _ENABLED is None and not self.enabled):
|
||||
return request.get_response(self.application)
|
||||
|
||||
trace_info = utils.signed_unpack(request.headers.get(X_TRACE_INFO),
|
||||
|
@ -1,4 +1,4 @@
|
||||
hacking>=3.0,<3.1.0 # Apache-2.0
|
||||
hacking>=3.1.0,<3.2.0 # Apache-2.0
|
||||
flake8-import-order==0.18.1 # LGPLv3
|
||||
|
||||
coverage>=4.0 # Apache-2.0
|
||||
|
3
tox.ini
3
tox.ini
@ -61,6 +61,9 @@ commands = bandit -r osprofiler -n5
|
||||
[flake8]
|
||||
show-source = true
|
||||
builtins = _
|
||||
# E741 ambiguous variable name 'l'
|
||||
# W503 line break before binary operator
|
||||
ignore = E741,W503
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools,setup.py,build,releasenotes
|
||||
import-order-style = pep8
|
||||
application-import-names = osprofiler
|
||||
|
Loading…
x
Reference in New Issue
Block a user