Skip to content

Commit 64166c4

Browse files
committed
resolve flake8 and black issues
1 parent 5e8b3c4 commit 64166c4

File tree

6 files changed

+41
-32
lines changed

6 files changed

+41
-32
lines changed

ddtrace/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
from .internal.import_hooks import patch as patch_import_hooks
77
patch_import_hooks() # noqa: E402
88

9-
from .monkey import patch, patch_all
10-
from .pin import Pin
11-
from .span import Span
12-
from .tracer import Tracer
13-
from .settings import config
9+
from .monkey import patch, patch_all # noqa: E402
10+
from .pin import Pin # noqa: E402
11+
from .span import Span # noqa: E402
12+
from .tracer import Tracer # noqa: E402
13+
from .settings import config # noqa: E402
1414

1515

1616
try:

ddtrace/compat.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
from ddtrace.vendor import six
77

88
__all__ = [
9-
'httplib',
10-
'iteritems',
11-
'PY2',
12-
'Queue',
13-
'stringify',
14-
'StringIO',
15-
'urlencode',
16-
'parse',
17-
'reraise',
9+
"httplib",
10+
"iteritems",
11+
"PY2",
12+
"Queue",
13+
"stringify",
14+
"StringIO",
15+
"urlencode",
16+
"parse",
17+
"reraise",
1818
]
1919

2020
PYTHON_VERSION_INFO = sys.version_info
@@ -42,7 +42,7 @@
4242
string_type = six.string_types[0]
4343
msgpack_type = six.binary_type
4444
# DEV: `six` doesn't have `float` in `integer_types`
45-
numeric_types = six.integer_types + (float, )
45+
numeric_types = six.integer_types + (float,)
4646

4747
# Pattern class generated by `re.compile`
4848
if PYTHON_VERSION_INFO >= (3, 7):
@@ -76,7 +76,9 @@ def time_ns():
7676
# Execute from a string to get around syntax errors from `yield from`
7777
# DEV: The idea to do this was stolen from `six`
7878
# https://github.com/benjaminp/six/blob/15e31431af97e5e64b80af0a3f598d382bcdd49a/six.py#L719-L737
79-
six.exec_(textwrap.dedent("""
79+
six.exec_(
80+
textwrap.dedent(
81+
"""
8082
import functools
8183
import asyncio
8284
@@ -100,7 +102,9 @@ def func_wrapper(*args, **kwargs):
100102
return result
101103
102104
return func_wrapper
103-
"""))
105+
"""
106+
)
107+
)
104108

105109
else:
106110
# asyncio is missing so we can't have coroutines; these
@@ -112,6 +116,7 @@ def iscoroutinefunction(fn):
112116
def make_async_decorator(tracer, fn, *params, **kw_params):
113117
return fn
114118

119+
115120
# static version of getattr backported from Python 3.7
116121
try:
117122
from inspect import getattr_static
@@ -121,7 +126,7 @@ def make_async_decorator(tracer, fn, *params, **kw_params):
121126
_sentinel = object()
122127

123128
def _static_getmro(klass):
124-
return type.__dict__['__mro__'].__get__(klass)
129+
return type.__dict__["__mro__"].__get__(klass)
125130

126131
def _check_instance(obj, attr):
127132
instance_dict = {}
@@ -155,9 +160,11 @@ def _shadowed_dict(klass):
155160
except KeyError:
156161
pass
157162
else:
158-
if not (type(class_dict) is types.GetSetDescriptorType and # noqa: E721,E261,W504
159-
class_dict.__name__ == "__dict__" and # noqa: E261,W504
160-
class_dict.__objclass__ is entry):
163+
if not (
164+
type(class_dict) is types.GetSetDescriptorType # noqa: E721
165+
and class_dict.__name__ == "__dict__" # noqa: E721,E261,W504
166+
and class_dict.__objclass__ is entry # noqa: E261,W504
167+
):
161168
return class_dict
162169
return _sentinel
163170

@@ -176,17 +183,18 @@ def getattr_static(obj, attr, default=_sentinel):
176183
if not _is_type(obj):
177184
klass = type(obj)
178185
dict_attr = _shadowed_dict(klass)
179-
if (dict_attr is _sentinel or # noqa: E261,E721,W504
180-
type(dict_attr) is types.MemberDescriptorType):
186+
if dict_attr is _sentinel or type(dict_attr) is types.MemberDescriptorType: # noqa: E261,E721,W504
181187
instance_result = _check_instance(obj, attr)
182188
else:
183189
klass = obj
184190

185191
klass_result = _check_class(klass, attr)
186192

187193
if instance_result is not _sentinel and klass_result is not _sentinel:
188-
if (_check_class(type(klass_result), '__get__') is not _sentinel and # noqa: W504,E261,E721
189-
_check_class(type(klass_result), '__set__') is not _sentinel):
194+
if (
195+
_check_class(type(klass_result), "__get__") is not _sentinel
196+
and _check_class(type(klass_result), "__set__") is not _sentinel # noqa: W504,E261,E721
197+
):
190198
return klass_result
191199

192200
if instance_result is not _sentinel:
@@ -219,8 +227,8 @@ def to_unicode(s):
219227

220228
# If the object has a `decode` method, then decode into `utf-8`
221229
# e.g. Python 2 `str`, Python 2/3 `bytearray`, etc
222-
if hasattr(s, 'decode'):
223-
return s.decode('utf-8')
230+
if hasattr(s, "decode"):
231+
return s.decode("utf-8")
224232

225233
# Always try to coerce the object into the `six.text_type` object we expect
226234
# e.g. `to_unicode(1)`, `to_unicode(dict(key='value'))`

ddtrace/opentracer/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(self, service_name=None, config=None, scope_manager=None, dd_tracer
6868
invalid_keys = config_invalid_keys(self._config)
6969
if invalid_keys:
7070
str_invalid_keys = ','.join(invalid_keys)
71-
raise ConfigException('invalid key(s) given (%s)'.format(str_invalid_keys))
71+
raise ConfigException('invalid key(s) given ({})'.format(str_invalid_keys))
7272

7373
if not self._service_name:
7474
raise ConfigException(""" Cannot detect the \'service_name\'.

ddtrace/span.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def pprint(self):
373373
]
374374

375375
lines.extend((' ', '%s:%s' % kv) for kv in sorted(self.meta.items()))
376-
return '\n'.join('%10s %s' % l for l in lines)
376+
return '\n'.join('%10s %s' % line for line in lines)
377377

378378
@property
379379
def context(self):

tests/contrib/asyncio/test_tracer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def test_trace_multiple_coroutines_ot_inner(self):
370370
# if multiple coroutines have nested tracing, they must belong
371371
# to the same trace
372372
ot_tracer = init_tracer('asyncio_svc', self.tracer)
373+
373374
@asyncio.coroutine
374375
def coro():
375376
# another traced coroutine

tests/internal/runtime/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ def cgroup_line_valid_test_cases():
5050

5151
valid_test_cases = dict(
5252
(
53-
':'.join([id, ','.join(groups), path.format(container_id, pod_id)]),
53+
':'.join([id_, ','.join(groups), path.format(container_id, pod_id)]),
5454
CGroupInfo(
55-
id=id,
55+
id=id_,
5656
groups=','.join(groups),
5757
path=path.format(container_id, pod_id),
5858
controllers=groups,
5959
container_id=container_id if '{0}' in path else None,
6060
pod_id=pod_id if '{1}' in path else None,
6161
)
6262
)
63-
for path, id, groups, container_id, pod_id
63+
for path, id_, groups, container_id, pod_id
6464
in itertools.product(paths, ids, controllers, container_ids, pod_ids)
6565
)
6666
# Dedupe test cases

0 commit comments

Comments
 (0)