8000 fix linters · lmasikl/sentry-python@647e9e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 647e9e2

Browse files
committed
fix linters
1 parent 0524821 commit 647e9e2

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ ignore_missing_imports = True
4646
ignore_missing_imports = True
4747
[mypy-pyspark.*]
4848
ignore_missing_imports = True
49+
[mypy-asgiref.*]
50+
ignore_missing_imports = True

sentry_sdk/integrations/django/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ def _patch_django_asgi_handler():
308308

309309

310310
def _before_get_response(request):
311+
# type: (WSGIRequest) -> None
311312
hub = Hub.current
312313
integration = hub.get_integration(DjangoIntegration)
313314
if integration is None:
@@ -333,6 +334,7 @@ def _before_get_response(request):
333334

334335

335336
def _patch_get_response():
337+
# type: () -> None
336338
"""
337339
patch get_response, because at that point wea have the Django request object
338340
"""
@@ -349,6 +351,7 @@ def sentry_patched_get_response(self, request):
349351

350352
if hasattr(BaseHandler, "get_response_async"):
351353
from sentry_sdk.integrations.django.asgi import patch_get_response_async
354+
352355
patch_get_response_async(BaseHandler, _before_get_response)
353356

354357

sentry_sdk/integrations/django/asgi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
if MYPY:
1616
from typing import Any
17+
from typing import Union
18+
19+
from django.http.response import HttpResponse
1720

1821

1922
def patch_django_asgi_handler_impl(cls):
@@ -32,10 +35,11 @@ async def sentry_patched_asgi_handler(self, scope, receive, send):
3235

3336

3437
def patch_get_response_async(cls, _before_get_response):
38+
# type: (Any, Any) -> None
3539
old_get_response_async = cls.get_response_async
3640

3741
async def sentry_patched_get_response_async(self, request):
38-
# type: (Any, WSGIRequest) -> Union[HttpResponse, BaseException]
42+
# type: (Any, Any) -> Union[HttpResponse, BaseException]
3943
_before_get_response(request)
4044
return await old_get_response_async(self, request)
4145

sentry_sdk/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ def _is_contextvars_broken():
747747

748748

749749
def _make_threadlocal_contextvars(local):
750+
# type: (type) -> type
750751
class ContextVar(object):
751752
# Super-limited impl of ContextVar
752753

@@ -786,13 +787,13 @@ def _get_contextvars():
786787
# API for integrations to swap out implementations dynamically. Django and
787788
# ASGI may be used in one process, but unused in another.
788789
try:
789-
from asgiref.local import Local as asgiref_local
790+
from asgiref.local import Local
790791
except ImportError:
791792
pass
792793
else:
793794
# Return True here because asgiref.local works correctly for ASGI
794795
# environments
795-
return True, _make_threadlocal_contextvars(asgiref_local)
796+
return True, _make_threadlocal_contextvars(Local)
796797

797798
if not _is_contextvars_broken():
798799
# aiocontextvars is a PyPI package that ensures that the contextvars
@@ -814,10 +815,7 @@ def _get_contextvars():
814815
except ImportError:
815816
pass
816817

817-
if asgiref_local is not None:
818-
local = asgiref_local
819-
else:
820-
from threading import local
818+
from threading import local
821819

822820
return False, _make_threadlocal_contextvars(local)
823821

0 commit comments

Comments
 (0)
0