Skip to content

Commit f3e93c8

Browse files
committed
chore(fastapi): formatting after ruff auto-fix
1 parent b5149ac commit f3e93c8

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
186186
import logging
187187
import types
188188
from typing import Collection, Literal
189+
from weakref import WeakSet as _WeakSet
189190

190191
import fastapi
191192
from starlette.applications import Starlette
@@ -415,9 +416,7 @@ class _InstrumentedFastAPI(fastapi.FastAPI):
415416
_exclude_spans: list[Literal["receive", "send"]] | None = None
416417

417418
# Track instrumented app instances using weak references to avoid GC leaks
418-
from weakref import WeakSet as _WeakSet # type: ignore
419-
420-
_instrumented_fastapi_apps: "_InstrumentedFastAPI._WeakSet" = _WeakSet()
419+
_instrumented_fastapi_apps = _WeakSet()
421420
_sem_conv_opt_in_mode = _StabilityMode.DEFAULT
422421

423422
def __init__(self, *args, **kwargs):

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,14 +1402,14 @@ def test_mark_span_internal_in_presence_of_span_from_other_framework(self):
14021402

14031403
class TestFastAPIGarbageCollection(unittest.TestCase):
14041404
def test_fastapi_app_is_collected_after_instrument(self):
1405-
import gc
1406-
import weakref
1405+
import gc as _gc
1406+
import weakref as _weakref
14071407

14081408
app = fastapi.FastAPI()
14091409
otel_fastapi.FastAPIInstrumentor().instrument_app(app)
1410-
app_ref = weakref.ref(app)
1410+
app_ref = _weakref.ref(app)
14111411
del app
1412-
gc.collect()
1412+
_gc.collect()
14131413
self.assertIsNone(app_ref())
14141414

14151415

0 commit comments

Comments
 (0)