Skip to content

Commit 11f3eb1

Browse files
authored
Update to FastAPI (#1513)
* Fixed FastAPI naming. * Made ignoring imports in mypy more explicit.
1 parent fabba69 commit 11f3eb1

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

mypy.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,3 @@ disallow_untyped_defs = False
6363
ignore_missing_imports = True
6464
[mypy-flask.signals]
6565
ignore_missing_imports = True
66-
[mypy-starlette.*]
67-
ignore_missing_imports = True
68-
[mypy-fastapi.*]
69-
ignore_missing_imports = True

sentry_sdk/integrations/fastapi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
from sentry_sdk._types import Event
1515

1616
try:
17-
from fastapi.applications import FastAPI
18-
from fastapi.requests import Request
17+
from fastapi import FastAPI # type: ignore
18+
from fastapi import Request
1919
except ImportError:
2020
raise DidNotEnable("FastAPI is not installed")
2121

2222
try:
23-
from starlette.types import ASGIApp, Receive, Scope, Send
23+
from starlette.types import ASGIApp, Receive, Scope, Send # type: ignore
2424
except ImportError:
2525
raise DidNotEnable("Starlette is not installed")
2626

2727

28-
_DEFAULT_TRANSACTION_NAME = "generic FastApi request"
28+
_DEFAULT_TRANSACTION_NAME = "generic FastAPI request"
2929

3030

3131
class FastApiIntegration(StarletteIntegration):

sentry_sdk/integrations/starlette.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@
2424
from sentry_sdk._types import Event
2525

2626
try:
27-
from starlette.applications import Starlette
28-
from starlette.datastructures import UploadFile
29-
from starlette.middleware import Middleware
30-
from starlette.middleware.authentication import AuthenticationMiddleware
31-
from starlette.requests import Request
32-
from starlette.routing import Match
33-
from starlette.types import ASGIApp, Receive, Scope, Send
27+
from starlette.applications import Starlette # type: ignore
28+
from starlette.datastructures import UploadFile # type: ignore
29+
from starlette.middleware import Middleware # type: ignore
30+
from starlette.middleware.authentication import AuthenticationMiddleware # type: ignore
31+
from starlette.requests import Request # type: ignore
32+
from starlette.routing import Match # type: ignore
33+
from starlette.types import ASGIApp, Receive, Scope, Send # type: ignore
3434
except ImportError:
3535
raise DidNotEnable("Starlette is not installed")
3636

3737
try:
38-
from starlette.middle.exceptions import ExceptionMiddleware # Starlette 0.20
38+
# Starlette 0.20
39+
from starlette.middleware.exceptions import ExceptionMiddleware # type: ignore
3940
except ImportError:
40-
from starlette.exceptions import ExceptionMiddleware # Startlette 0.19.1
41+
# Startlette 0.19.1
42+
from starlette.exceptions import ExceptionMiddleware # type: ignore
4143

4244

4345
_DEFAULT_TRANSACTION_NAME = "generic Starlette request"

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def get_file_text(file_name):
5656
"chalice": ["chalice>=1.16.0"],
5757
"httpx": ["httpx>=0.16.0"],
5858
"starlette": ["starlette>=0.19.1"],
59+
"fastapi": ["fastapi>=0.79.0"],
5960
},
6061
classifiers=[
6162
"Development Status :: 5 - Production/Stable",

0 commit comments

Comments
 (0)