Skip to content

Commit

Permalink
ref: Define types at runtime (#2914)
Browse files Browse the repository at this point in the history
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 <anton.pirker@sentry.io>
Co-authored-by: anthony sottile <103459774+asottile-sentry@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 27, 2024
1 parent 790ee6a commit 6c2eb53
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sentry_sdk/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from sentry_sdk._types import Event, Hint # noqa: F401
from sentry_sdk._types import Event, Hint
else:
# The lines below allow the types to be imported from outside `if TYPE_CHECKING`
# guards. The types in this module are only intended to be used for type hints.
Event = None
Hint = None

__all__ = ["Event", "Hint"]
__all__ = ("Event", "Hint")

0 comments on commit 6c2eb53

Please sign in to comment.