summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--osprofiler/cmd/shell.py6
-rw-r--r--osprofiler/drivers/base.py15
-rw-r--r--osprofiler/hacking/checks.py23
-rw-r--r--osprofiler/profiler.py4
-rw-r--r--osprofiler/tests/unit/drivers/test_loginsight.py2
-rw-r--r--osprofiler/tests/unit/drivers/test_mongodb.py5
-rw-r--r--osprofiler/tests/unit/drivers/test_redis_driver.py9
-rw-r--r--osprofiler/web.py4
-rw-r--r--test-requirements.txt2
-rw-r--r--tox.ini3
10 files changed, 38 insertions, 35 deletions
diff --git a/osprofiler/cmd/shell.py b/osprofiler/cmd/shell.py
index 5fe0163..6288659 100644
--- a/osprofiler/cmd/shell.py
+++ b/osprofiler/cmd/shell.py
@@ -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
diff --git a/osprofiler/drivers/base.py b/osprofiler/drivers/base.py
index b85ffda..bb0dc7e 100644
--- a/osprofiler/drivers/base.py
+++ b/osprofiler/drivers/base.py
@@ -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
diff --git a/osprofiler/hacking/checks.py b/osprofiler/hacking/checks.py
index c77e91d..b31a47d 100644
--- a/osprofiler/hacking/checks.py
+++ b/osprofiler/hacking/checks.py
@@ -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 = ""
diff --git a/osprofiler/profiler.py b/osprofiler/profiler.py
index 42bcc28..7949f0e 100644
--- a/osprofiler/profiler.py
+++ b/osprofiler/profiler.py
@@ -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
diff --git a/osprofiler/tests/unit/drivers/test_loginsight.py b/osprofiler/tests/unit/drivers/test_loginsight.py
index b05ea98..936b7e4 100644
--- a/osprofiler/tests/unit/drivers/test_loginsight.py
+++ b/osprofiler/tests/unit/drivers/test_loginsight.py
@@ -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)
diff --git a/osprofiler/tests/unit/drivers/test_mongodb.py b/osprofiler/tests/unit/drivers/test_mongodb.py
index b11b97f..6037653 100644
--- a/osprofiler/tests/unit/drivers/test_mongodb.py
+++ b/osprofiler/tests/unit/drivers/test_mongodb.py
@@ -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}}}
diff --git a/osprofiler/tests/unit/drivers/test_redis_driver.py b/osprofiler/tests/unit/drivers/test_redis_driver.py
index 2e7a8e0..b8d3e5e 100644
--- a/osprofiler/tests/unit/drivers/test_redis_driver.py
+++ b/osprofiler/tests/unit/drivers/test_redis_driver.py
@@ -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}}}
diff --git a/osprofiler/web.py b/osprofiler/web.py
index 8443ca5..20875b1 100644
--- a/osprofiler/web.py
+++ b/osprofiler/web.py
@@ -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),
diff --git a/test-requirements.txt b/test-requirements.txt
index 766c4d4..41b3580 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -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
diff --git a/tox.ini b/tox.ini
index 7553b3b..112fd78 100644
--- a/tox.ini
+++ b/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