Skip to content

Commit fa6ec70

Browse files
committed
Improved typing
1 parent ddf0fe6 commit fa6ec70

File tree

8 files changed

+23
-21
lines changed

8 files changed

+23
-21
lines changed

sentry_sdk/integrations/aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async def sentry_urldispatcher_resolve(self, request):
157157

158158
scope.set_transaction_name(
159159
name,
160-
source=source_for_style.get(integration.transaction_style),
160+
source=source_for_style[integration.transaction_style],
161161
)
162162

163163
return rv

sentry_sdk/integrations/bottle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
class BottleIntegration(Integration):
4343
identifier = "bottle"
4444

45-
transaction_style = None
45+
transaction_style = ""
4646

4747
def __init__(self, transaction_style="endpoint"):
4848
# type: (str) -> None

sentry_sdk/integrations/chalice.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from sentry_sdk._types import MYPY
1313
from sentry_sdk._functools import wraps
1414

15-
import chalice # type: ignore
15+
import chalice
1616
from chalice import Chalice, ChaliceViewError
17-
from chalice.app import EventSourceHandler as ChaliceEventSourceHandler # type: ignore
17+
from chalice.app import EventSourceHandler as ChaliceEventSourceHandler
1818

1919
if MYPY:
2020
from typing import Any
@@ -30,7 +30,7 @@
3030
raise DidNotEnable("Chalice is not installed")
3131

3232

33-
class EventSourceHandler(ChaliceEventSourceHandler): # type: ignore
33+
class EventSourceHandler(ChaliceEventSourceHandler):
3434
def __call__(self, event, context):
3535
# type: (Any, Any) -> Any
3636
hub = Hub.current

sentry_sdk/integrations/django/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def is_authenticated(request_user):
8484
class DjangoIntegration(Integration):
8585
identifier = "django"
8686

87-
transaction_style = None
87+
transaction_style = ""
8888
middleware_spans = None
8989

9090
def __init__(self, transaction_style="url", middleware_spans=True):
@@ -324,10 +324,12 @@ def _patch_django_asgi_handler():
324324
def _set_transaction_name_and_source(scope, transaction_style, request):
325325
# type: (Scope, str, WSGIRequest) -> Scope
326326
try:
327-
transaction_name = None
327+
transaction_name = ""
328328
if transaction_style == "function_name":
329329
fn = resolve(request.path).func
330-
transaction_name = transaction_from_function(getattr(fn, "view_class", fn))
330+
transaction_name = (
331+
transaction_from_function(getattr(fn, "view_class", fn)) or ""
332+
)
331333

332334
elif transaction_style == "url":
333335
if hasattr(request, "urlconf"):
@@ -344,7 +346,7 @@ def _set_transaction_name_and_source(scope, transaction_style, request):
344346

345347
scope.set_transaction_name(
346348
transaction_name,
347-
source=source_for_style.get(transaction_style),
349+
source=source_for_style[transaction_style],
348350
)
349351
except Exception:
350352
pass

sentry_sdk/integrations/falcon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def process_request(self, req, resp, *args, **kwargs):
9292
class FalconIntegration(Integration):
9393
identifier = "falcon"
9494

95-
transaction_style = None
95+
transaction_style = ""
9696

9797
def __init__(self, transaction_style="uri_template"):
9898
# type: (str) -> None

sentry_sdk/integrations/flask.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
try:
3030
from flask import Flask, Markup, Request # type: ignore
31-
from flask import __version__ as FLASK_VERSION # type: ignore
32-
from flask import _app_ctx_stack, _request_ctx_stack # type: ignore
31+
from flask import __version__ as FLASK_VERSION
32+
from flask import _app_ctx_stack, _request_ctx_stack
3333
from flask.signals import (
3434
before_render_template,
3535
got_request_exception,
@@ -49,7 +49,7 @@
4949
class FlaskIntegration(Integration):
5050
identifier = "flask"
5151

52-
transaction_style = None
52+
transaction_style = ""
5353

5454
def __init__(self, transaction_style="endpoint"):
5555
# type: (str) -> None
@@ -123,8 +123,8 @@ def _set_transaction_name_and_source(scope, transaction_style, request):
123123
}
124124

125125
scope.set_transaction_name(
126-
name_for_style.get(transaction_style),
127-
source=source_for_style.get(transaction_style),
126+
name_for_style[transaction_style],
127+
source=source_for_style[transaction_style],
128128
)
129129
except Exception:
130130
pass

sentry_sdk/integrations/pyramid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def authenticated_userid(request):
5757
class PyramidIntegration(Integration):
5858
identifier = "pyramid"
5959

60-
transaction_style = None
60+
transaction_style = ""
6161

6262
def __init__(self, transaction_style="route_name"):
6363
# type: (str) -> None
@@ -170,8 +170,8 @@ def _set_transaction_name_and_source(scope, transaction_style, request):
170170
}
171171

172172
scope.set_transaction_name(
173-
name_for_style.get(transaction_style),
174-
source=source_for_style.get(transaction_style),
173+
name_for_style[transaction_style],
174+
source=source_for_style[transaction_style],
175175
)
176176
except Exception:
177177
pass

sentry_sdk/integrations/quart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
class QuartIntegration(Integration):
5151
identifier = "quart"
5252

53-
transaction_style = None
53+
transaction_style = ""
5454

5555
def __init__(self, transaction_style="endpoint"):
5656
# type: (str) -> None
@@ -99,8 +99,8 @@ def _set_transaction_name_and_source(scope, transaction_style, request):
9999
}
100100

101101
scope.set_transaction_name(
102-
name_for_style.get(transaction_style),
103-
source=source_for_style.get(transaction_style),
102+
name_for_style[transaction_style],
103+
source=source_for_style[transaction_style],
104104
)
105105
except Exception:
106106
pass

0 commit comments

Comments
 (0)