66from 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
2020PYTHON_VERSION_INFO = sys .version_info
4242string_type = six .string_types [0 ]
4343msgpack_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`
4848if 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
105109else :
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
116121try :
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'))`
0 commit comments