Skip to content

Commit b7c382f

Browse files
ref(tracing_utils): Use type comments instead of type annotations
1 parent c6ce9c7 commit b7c382f

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

sentry_sdk/tracing_utils.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
_module_in_list,
2626
)
2727

28-
from typing import List, Optional, TYPE_CHECKING
28+
from typing import TYPE_CHECKING
2929

3030
if TYPE_CHECKING:
3131
from typing import Any
3232
from typing import Dict
3333
from typing import Generator
34+
from typing import Optional
3435
from typing import Union
3536

3637
from types import FrameType
@@ -180,13 +181,14 @@ def _get_frame_module_abs_path(frame):
180181

181182

182183
def _should_be_included(
183-
is_sentry_sdk_frame: bool,
184-
namespace: Optional[str],
185-
in_app_include: Optional[List[str]],
186-
in_app_exclude: Optional[List[str]],
187-
abs_path: Optional[str],
188-
project_root: Optional[str],
189-
) -> bool:
184+
is_sentry_sdk_frame, # type: bool
185+
namespace, # type: Optional[str]
186+
in_app_include, # type: Optional[list[str]]
187+
in_app_exclude, # type: Optional[list[str]]
188+
abs_path, # type: Optional[str]
189+
project_root, # type: Optional[str]
190+
):
191+
# type: (...) -> bool
190192
# in_app_include takes precedence over in_app_exclude
191193
should_be_included = _module_in_list(namespace, in_app_include)
192194
should_be_excluded = _is_external_source(abs_path) or _module_in_list(

tests/test_tracing_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from dataclasses import asdict, dataclass
2-
from typing import Optional, List, Any
2+
from typing import Optional, List
33

44
from sentry_sdk.tracing_utils import _should_be_included
55
import pytest
66

77

8-
def id_function(val: Any) -> str:
8+
def id_function(val):
9+
# type: (object) -> str
910
if isinstance(val, ShouldBeIncludedTestCase):
1011
return val.id
1112

@@ -87,9 +88,8 @@ class ShouldBeIncludedTestCase:
8788
],
8889
ids=id_function,
8990
)
90-
def test_should_be_included(
91-
test_case: ShouldBeIncludedTestCase, expected: bool
92-
) -> None:
91+
def test_should_be_included(test_case, expected):
92+
# type: (ShouldBeIncludedTestCase, bool) -> None
9393
"""Checking logic, see: https://github.com/getsentry/sentry-python/issues/3312"""
9494
kwargs = asdict(test_case)
9595
kwargs.pop("id")

0 commit comments

Comments
 (0)