Skip to content

Commit

Permalink
Fix check for Starlette in FastAPI integration (#1868)
Browse files Browse the repository at this point in the history
When loading FastAPI integration also check if StarletteIntegration can actually be loaded. (Because Starlette is a requirement for FastAPI)

Fixes #1603
  • Loading branch information
antonpirker committed Jan 30, 2023
1 parent 89a602b commit c2ed5ec
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sentry_sdk/integrations/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
from sentry_sdk._types import MYPY
from sentry_sdk.hub import Hub, _should_send_default_pii
from sentry_sdk.integrations import DidNotEnable
from sentry_sdk.integrations.starlette import (
StarletteIntegration,
StarletteRequestExtractor,
)
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.utils import transaction_from_function

if MYPY:
from typing import Any, Callable, Dict

from sentry_sdk.scope import Scope

try:
from sentry_sdk.integrations.starlette import (
StarletteIntegration,
StarletteRequestExtractor,
)
except DidNotEnable:
raise DidNotEnable("Starlette is not installed")

try:
import fastapi # type: ignore
except ImportError:
Expand Down

0 comments on commit c2ed5ec

Please sign in to comment.