Skip to content

Commit 6c2eb53

Browse files
szokeasaurusrexantonpirkerasottile-sentry
authored
ref: Define types at runtime (#2914)
Set types in sentry_sdk.types to None at runtime. This allows the types to be imported from outside if TYPE_CHECKING guards. Fixes GH-2909 Co-authored-by: Anton Pirker <[email protected]> Co-authored-by: anthony sottile <[email protected]>
1 parent 790ee6a commit 6c2eb53

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sentry_sdk/types.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
from typing import TYPE_CHECKING
1212

1313
if TYPE_CHECKING:
14-
from sentry_sdk._types import Event, Hint # noqa: F401
14+
from sentry_sdk._types import Event, Hint
15+
else:
16+
# The lines below allow the types to be imported from outside `if TYPE_CHECKING`
17+
# guards. The types in this module are only intended to be used for type hints.
18+
Event = None
19+
Hint = None
1520

16-
__all__ = ["Event", "Hint"]
21+
__all__ = ("Event", "Hint")

0 commit comments

Comments
 (0)