File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 13
13
if TYPE_CHECKING :
14
14
from sentry_sdk ._types import Event , Hint
15
15
else :
16
+ from typing import Any
17
+
16
18
# The lines below allow the types to be imported from outside `if TYPE_CHECKING`
17
19
# guards. The types in this module are only intended to be used for type hints.
18
- Event = None
19
- Hint = None
20
+ Event = Any
21
+ Hint = Any
20
22
21
23
__all__ = ("Event" , "Hint" )
Original file line number Diff line number Diff line change
1
+ import sys
2
+
3
+ import pytest
4
+ from sentry_sdk .types import Event , Hint
5
+
6
+
7
+ @pytest .mark .skipif (
8
+ sys .version_info < (3 , 10 ),
9
+ reason = "Type hinting with `|` is available in Python 3.10+" ,
10
+ )
11
+ def test_event_or_none_runtime ():
12
+ """
13
+ Ensures that the `Event` type's runtime value supports the `|` operation with `None`.
14
+ This test is needed to ensure that using an `Event | None` type hint (e.g. for
15
+ `before_send`'s return value) does not raise a TypeError at runtime.
16
+ """
17
+ Event | None
18
+
19
+
20
+ @pytest .mark .skipif (
21
+ sys .version_info < (3 , 10 ),
22
+ reason = "Type hinting with `|` is available in Python 3.10+" ,
23
+ )
24
+ def test_hint_or_none_runtime ():
25
+ """
26
+ Analogue to `test_event_or_none_runtime`, but for the `Hint` type.
27
+ """
28
+ Hint | None
You can’t perform that action at this time.
0 commit comments