Skip to content

Commit 3137c1f

Browse files
authored
Upgrade black (open-telemetry#802)
1 parent f4d09f9 commit 3137c1f

File tree

70 files changed

+352
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+352
-147
lines changed

.python-version

-1
This file was deleted.

dev-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pylint<2.10
22
flake8~=3.7
33
isort~=5.6
4-
black>=19.3b0,==19.*
4+
black>=21.10b0
55
httpretty~=1.0
66
mypy==0.790
77
sphinx

docs/conf.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,22 @@ def getlistcfg(strval):
129129
if "class_references" in mcfg:
130130
class_references = getlistcfg(mcfg["class_references"])
131131
for class_reference in class_references:
132-
nitpick_ignore.append(("py:class", class_reference,))
132+
nitpick_ignore.append(
133+
(
134+
"py:class",
135+
class_reference,
136+
)
137+
)
133138

134139
if "anys" in mcfg:
135140
anys = getlistcfg(mcfg["anys"])
136141
for _any in anys:
137-
nitpick_ignore.append(("any", _any,))
142+
nitpick_ignore.append(
143+
(
144+
"any",
145+
_any,
146+
)
147+
)
138148

139149
# Add any paths that contain templates here, relative to this directory.
140150
templates_path = ["_templates"]

exporter/opentelemetry-exporter-datadog/src/opentelemetry/exporter/datadog/propagator.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def inject(
9696
return
9797
sampled = (trace.TraceFlags.SAMPLED & span.context.trace_flags) != 0
9898
setter.set(
99-
carrier, self.TRACE_ID_KEY, format_trace_id(span.context.trace_id),
99+
carrier,
100+
self.TRACE_ID_KEY,
101+
format_trace_id(span.context.trace_id),
100102
)
101103
setter.set(
102104
carrier, self.PARENT_ID_KEY, format_span_id(span.context.span_id)

exporter/opentelemetry-exporter-datadog/tests/test_datadog_exporter.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def test_constructor_explicit(self):
7878
"""Test the constructor passing all the options."""
7979
agent_url = "http://localhost:8126"
8080
exporter = datadog.DatadogSpanExporter(
81-
agent_url=agent_url, service="explicit",
81+
agent_url=agent_url,
82+
service="explicit",
8283
)
8384

8485
self.assertEqual(exporter.agent_url, agent_url)
@@ -472,7 +473,8 @@ def test_span_processor_dropped_spans(self):
472473
tracer_provider.shutdown()
473474

474475
@mark.skipif(
475-
sys.platform == "win32", reason="unreliable test on windows",
476+
sys.platform == "win32",
477+
reason="unreliable test on windows",
476478
)
477479
def test_span_processor_scheduled_delay(self):
478480
"""Test that spans are exported each schedule_delay_millis"""

exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ class RichConsoleSpanExporter(SpanExporter):
132132
"""
133133

134134
def __init__(
135-
self, service_name: Optional[str] = None,
135+
self,
136+
service_name: Optional[str] = None,
136137
):
137138
self.service_name = service_name
138139
self.console = Console()

instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ async def on_request_start(
201201
request_span_name = f"HTTP {http_method}"
202202

203203
trace_config_ctx.span = trace_config_ctx.tracer.start_span(
204-
request_span_name, kind=SpanKind.CLIENT,
204+
request_span_name,
205+
kind=SpanKind.CLIENT,
205206
)
206207

207208
if callable(request_hook):

instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def test_status_codes(self):
116116
(HTTPStatus.OK, StatusCode.UNSET),
117117
(HTTPStatus.TEMPORARY_REDIRECT, StatusCode.UNSET),
118118
(HTTPStatus.SERVICE_UNAVAILABLE, StatusCode.ERROR),
119-
(HTTPStatus.GATEWAY_TIMEOUT, StatusCode.ERROR,),
119+
(
120+
HTTPStatus.GATEWAY_TIMEOUT,
121+
StatusCode.ERROR,
122+
),
120123
):
121124
with self.subTest(status_code=status_code):
122125
host, port = self._http_request(
@@ -178,7 +181,8 @@ def response_hook(
178181

179182
host, port = self._http_request(
180183
trace_config=aiohttp_client.create_trace_config(
181-
request_hook=request_hook, response_hook=response_hook,
184+
request_hook=request_hook,
185+
response_hook=response_hook,
182186
),
183187
method=method,
184188
url=path,

instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _instrument(self, **kwargs):
9191

9292
# pylint:disable=no-self-use
9393
def _uninstrument(self, **kwargs):
94-
""""Disable aiopg instrumentation"""
94+
""" "Disable aiopg instrumentation"""
9595
wrappers.unwrap_connect()
9696
wrappers.unwrap_create_pool()
9797

instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ async def __call__(self, scope, receive, send):
299299

300300
try:
301301
with self.tracer.start_as_current_span(
302-
span_name, kind=trace.SpanKind.SERVER,
302+
span_name,
303+
kind=trace.SpanKind.SERVER,
303304
) as span:
304305
if span.is_recording():
305306
attributes = collect_request_attributes(scope)

instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ def _determine_parent_context(
130130
) -> Context:
131131
"""Determine the parent context for the current Lambda invocation.
132132
133-
See more:
134-
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#determining-the-parent-of-a-span
133+
See more:
134+
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#determining-the-parent-of-a-span
135135
136-
Args:
137-
lambda_event: user-defined, so it could be anything, but this
138-
method counts it being a map with a 'headers' key
139-
Returns:
140-
A Context with configuration found in the carrier.
141-
"""
136+
Args:
137+
lambda_event: user-defined, so it could be anything, but this
138+
method counts it being a map with a 'headers' key
139+
Returns:
140+
A Context with configuration found in the carrier.
141+
"""
142142
parent_context = None
143143

144144
xray_env_var = os.environ.get(_X_AMZN_TRACE_ID)
@@ -194,7 +194,9 @@ def _instrumented_lambda_handler_call(
194194
tracer = get_tracer(__name__, __version__, tracer_provider)
195195

196196
with tracer.start_as_current_span(
197-
name=orig_handler_name, context=parent_context, kind=span_kind,
197+
name=orig_handler_name,
198+
context=parent_context,
199+
kind=span_kind,
198200
) as span:
199201
if span.is_recording():
200202
lambda_context = args[1]

instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ class TestAwsLambdaInstrumentor(TestBase):
9393
def setUp(self):
9494
super().setUp()
9595
self.common_env_patch = mock.patch.dict(
96-
"os.environ", {_HANDLER: "mocks.lambda_function.handler"},
96+
"os.environ",
97+
{_HANDLER: "mocks.lambda_function.handler"},
9798
)
9899
self.common_env_patch.start()
99100

instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def _common_request( # pylint: disable=too-many-locals
123123
endpoint_name = getattr(instance, "host").split(".")[0]
124124

125125
with self._tracer.start_as_current_span(
126-
f"{endpoint_name}.command", kind=SpanKind.CONSUMER,
126+
f"{endpoint_name}.command",
127+
kind=SpanKind.CONSUMER,
127128
) as span:
128129
span.set_attribute("endpoint", endpoint_name)
129130
if args:
@@ -135,7 +136,11 @@ def _common_request( # pylint: disable=too-many-locals
135136

136137
if span.is_recording():
137138
add_span_arg_tags(
138-
span, endpoint_name, args, args_name, traced_args,
139+
span,
140+
endpoint_name,
141+
args,
142+
args_name,
143+
traced_args,
139144
)
140145

141146
# Obtaining region name

instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_instrumentation.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ def assert_only_span(self):
9999
return spans[0]
100100

101101
def assert_span(
102-
self, service: str, operation: str, request_id=None, attributes=None,
102+
self,
103+
service: str,
104+
operation: str,
105+
request_id=None,
106+
attributes=None,
103107
):
104108
span = self.assert_only_span()
105109
expected = self._default_span_attributes(service, operation)

instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def _instrument(self, **kwargs):
131131

132132
tracer_provider = kwargs.get("tracer_provider")
133133
tracer = get_tracer(
134-
__name__, __version__, tracer_provider=tracer_provider,
134+
__name__,
135+
__version__,
136+
tracer_provider=tracer_provider,
135137
)
136138

137139
_DjangoMiddleware._tracer = tracer

instrumentation/opentelemetry-instrumentation-django/tests/test_middleware.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,23 @@ async def test_trace_parent(self):
356356
traceparent_value = f"00-{trace_id}-{span_id}-01"
357357

358358
Client().get(
359-
"/span_name/1234/", traceparent=traceparent_value,
359+
"/span_name/1234/",
360+
traceparent=traceparent_value,
360361
)
361362
span = self.memory_exporter.get_finished_spans()[0]
362363

363364
self.assertEqual(
364-
trace_id, format_trace_id(span.get_span_context().trace_id),
365+
trace_id,
366+
format_trace_id(span.get_span_context().trace_id),
365367
)
366368
self.assertIsNotNone(span.parent)
367369
self.assertEqual(
368-
trace_id, format_trace_id(span.parent.trace_id),
370+
trace_id,
371+
format_trace_id(span.parent.trace_id),
369372
)
370373
self.assertEqual(
371-
span_id, format_span_id(span.parent.span_id),
374+
span_id,
375+
format_span_id(span.parent.span_id),
372376
)
373377
self.memory_exporter.clear()
374378

@@ -382,7 +386,8 @@ def test_trace_response_headers(self):
382386

383387
response = Client().get("/span_name/1234/")
384388
self.assertTraceResponseHeaderMatchesSpan(
385-
response, self.memory_exporter.get_finished_spans()[0],
389+
response,
390+
self.memory_exporter.get_finished_spans()[0],
386391
)
387392
self.memory_exporter.clear()
388393

instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,23 @@ async def test_trace_parent(self):
330330
traceparent_value = f"00-{trace_id}-{span_id}-01"
331331

332332
await self.async_client.get(
333-
"/span_name/1234/", traceparent=traceparent_value,
333+
"/span_name/1234/",
334+
traceparent=traceparent_value,
334335
)
335336
span = self.memory_exporter.get_finished_spans()[0]
336337

337338
self.assertEqual(
338-
trace_id, format_trace_id(span.get_span_context().trace_id),
339+
trace_id,
340+
format_trace_id(span.get_span_context().trace_id),
339341
)
340342
self.assertIsNotNone(span.parent)
341343
self.assertEqual(
342-
trace_id, format_trace_id(span.parent.trace_id),
344+
trace_id,
345+
format_trace_id(span.parent.trace_id),
343346
)
344347
self.assertEqual(
345-
span_id, format_span_id(span.parent.span_id),
348+
span_id,
349+
format_span_id(span.parent.span_id),
346350
)
347351
self.memory_exporter.clear()
348352

@@ -359,7 +363,8 @@ async def test_trace_response_headers(self):
359363

360364
self.assertTrue(response.has_header("traceresponse"))
361365
self.assertEqual(
362-
response["Access-Control-Expose-Headers"], "traceresponse",
366+
response["Access-Control-Expose-Headers"],
367+
"traceresponse",
363368
)
364369
self.assertEqual(
365370
response["traceresponse"],

instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ class ElasticsearchInstrumentor(BaseInstrumentor):
119119
def __init__(self, span_name_prefix=None):
120120
if not span_name_prefix:
121121
span_name_prefix = environ.get(
122-
"OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX", "Elasticsearch",
122+
"OTEL_PYTHON_ELASTICSEARCH_NAME_PREFIX",
123+
"Elasticsearch",
123124
)
124125
self._span_name_prefix = span_name_prefix.strip()
125126
super().__init__()
@@ -187,7 +188,8 @@ def wrapper(wrapped, _, args, kwargs):
187188
body = kwargs.get("body", None)
188189

189190
with tracer.start_as_current_span(
190-
op_name, kind=SpanKind.CLIENT,
191+
op_name,
192+
kind=SpanKind.CLIENT,
191193
) as span:
192194

193195
if callable(request_hook):
@@ -215,7 +217,8 @@ def wrapper(wrapped, _, args, kwargs):
215217
for member in _ATTRIBUTES_FROM_RESULT:
216218
if member in rv:
217219
span.set_attribute(
218-
f"elasticsearch.{member}", str(rv[member]),
220+
f"elasticsearch.{member}",
221+
str(rv[member]),
219222
)
220223

221224
if callable(response_hook):

instrumentation/opentelemetry-instrumentation-falcon/src/opentelemetry/instrumentation/falcon/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ def _start_response(status, response_headers, *args, **kwargs):
222222
return super().__call__(env, _start_response)
223223
except Exception as exc:
224224
activation.__exit__(
225-
type(exc), exc, getattr(exc, "__traceback__", None),
225+
type(exc),
226+
exc,
227+
getattr(exc, "__traceback__", None),
226228
)
227229
context.detach(token)
228230
raise

instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def _test_method(self, method):
8888
self.assertEqual(span.name, f"HelloWorldResource.on_{method.lower()}")
8989
self.assertEqual(span.status.status_code, StatusCode.UNSET)
9090
self.assertEqual(
91-
span.status.description, None,
91+
span.status.description,
92+
None,
9293
)
9394
self.assertSpanHasAttributes(
9495
span,

instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ def _create_app_explicit_excluded_urls(self):
254254
to_exclude = "/user/123,/foobar"
255255
self._instrumentor.uninstrument() # Disable previous instrumentation (setUp)
256256
self._instrumentor.instrument(
257-
tracer_provider=tracer_provider, excluded_urls=to_exclude,
257+
tracer_provider=tracer_provider,
258+
excluded_urls=to_exclude,
258259
)
259260
return self._create_fastapi_app()
260261

instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ def instrument_app(
326326
tracer = trace.get_tracer(__name__, __version__, tracer_provider)
327327

328328
_before_request = _wrapped_before_request(
329-
request_hook, tracer, excluded_urls=excluded_urls,
329+
request_hook,
330+
tracer,
331+
excluded_urls=excluded_urls,
330332
)
331333
app._before_request = _before_request
332334
app.before_request(_before_request)

instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ def test_trace_response(self):
157157
self.assertEqual(len(span_list), 1)
158158

159159
self.assertTraceResponseHeaderMatchesSpan(
160-
response.headers, span_list[0],
160+
response.headers,
161+
span_list[0],
161162
)
162163

163164
set_global_response_propagator(orig)

instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ def instrumentation_dependencies(self) -> Collection[str]:
206206
def _instrument(self, **kwargs):
207207
for ctype in self._which_channel(kwargs):
208208
_wrap(
209-
"grpc", ctype, self.wrapper_fn,
209+
"grpc",
210+
ctype,
211+
self.wrapper_fn,
210212
)
211213

212214
def _uninstrument(self, **kwargs):
@@ -217,7 +219,8 @@ def wrapper_fn(self, original_func, instance, args, kwargs):
217219
channel = original_func(*args, **kwargs)
218220
tracer_provider = kwargs.get("tracer_provider")
219221
return intercept_channel(
220-
channel, client_interceptor(tracer_provider=tracer_provider),
222+
channel,
223+
client_interceptor(tracer_provider=tracer_provider),
221224
)
222225

223226

0 commit comments

Comments
 (0)