Skip to content

Commit

Permalink
ref(tracing_utils): Use type comments instead of type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
szokeasaurusrex committed Sep 23, 2024
1 parent c6ce9c7 commit b7c382f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
18 changes: 10 additions & 8 deletions sentry_sdk/tracing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
_module_in_list,
)

from typing import List, Optional, TYPE_CHECKING
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any
from typing import Dict
from typing import Generator
from typing import Optional
from typing import Union

from types import FrameType
Expand Down Expand Up @@ -180,13 +181,14 @@ def _get_frame_module_abs_path(frame):


def _should_be_included(
is_sentry_sdk_frame: bool,
namespace: Optional[str],
in_app_include: Optional[List[str]],
in_app_exclude: Optional[List[str]],
abs_path: Optional[str],
project_root: Optional[str],
) -> bool:
is_sentry_sdk_frame, # type: bool
namespace, # type: Optional[str]
in_app_include, # type: Optional[list[str]]
in_app_exclude, # type: Optional[list[str]]
abs_path, # type: Optional[str]
project_root, # type: Optional[str]
):
# type: (...) -> bool
# in_app_include takes precedence over in_app_exclude
should_be_included = _module_in_list(namespace, in_app_include)
should_be_excluded = _is_external_source(abs_path) or _module_in_list(
Expand Down
10 changes: 5 additions & 5 deletions tests/test_tracing_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from dataclasses import asdict, dataclass
from typing import Optional, List, Any
from typing import Optional, List

from sentry_sdk.tracing_utils import _should_be_included
import pytest


def id_function(val: Any) -> str:
def id_function(val):
# type: (object) -> str
if isinstance(val, ShouldBeIncludedTestCase):
return val.id

Expand Down Expand Up @@ -87,9 +88,8 @@ class ShouldBeIncludedTestCase:
],
ids=id_function,
)
def test_should_be_included(
test_case: ShouldBeIncludedTestCase, expected: bool
) -> None:
def test_should_be_included(test_case, expected):
# type: (ShouldBeIncludedTestCase, bool) -> None
"""Checking logic, see: https://github.com/getsentry/sentry-python/issues/3312"""
kwargs = asdict(test_case)
kwargs.pop("id")
Expand Down

0 comments on commit b7c382f

Please sign in to comment.