Skip to content

Commit d394b1a

Browse files
committed
Fix mypy issue
1 parent 1e080f7 commit d394b1a

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

mysql-connector-python/lib/mysql/connector/opentelemetry/instrumentation.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,9 @@ def with_cnx_span_attached(method: Callable) -> Callable:
212212

213213
def wrapper(cnx: "MySQLConnectionAbstract", *args: Any, **kwargs: Any) -> Any:
214214
"""Connection span attacher decorator."""
215-
with (
216-
trace.use_span(cnx._span, end_on_exit=False)
217-
if cnx._span and cnx._span.is_recording()
218-
else nullcontext()
219-
):
215+
with trace.use_span(
216+
cnx._span, end_on_exit=False
217+
) if cnx._span and cnx._span.is_recording() else nullcontext():
220218
return method(cnx, *args, **kwargs)
221219

222220
return wrapper
@@ -237,16 +235,12 @@ def wrapper(cnx: TracedMySQLConnection, *args: Any, **kwargs: Any) -> Any:
237235
"connection_type": cnx.get_wrapped_class(),
238236
}
239237

240-
with (
241-
cnx._tracer.start_as_current_span(
242-
name=method.__name__.upper(),
243-
kind=trace.SpanKind.CLIENT,
244-
links=[trace.Link(cnx._span.get_span_context())],
245-
attributes=query_span_attributes,
246-
)
247-
if cnx._span and cnx._span.is_recording()
248-
else nullcontext()
249-
):
238+
with cnx._tracer.start_as_current_span(
239+
name=method.__name__.upper(),
240+
kind=trace.SpanKind.CLIENT,
241+
links=[trace.Link(cnx._span.get_span_context())],
242+
attributes=query_span_attributes,
243+
) if cnx._span and cnx._span.is_recording() else nullcontext():
250244
return method(cnx, *args, **kwargs)
251245

252246
return wrapper

0 commit comments

Comments
 (0)