From 86fdea01f2c3640fbf82dd7aaf923ad9e7bf0ede Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Thu, 21 Mar 2024 10:27:09 +0100 Subject: [PATCH 1/4] Explicit reexport of types (#2866) * Explicitly reexport types to make strict mypy setups happy --- sentry_sdk/types.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sentry_sdk/types.py b/sentry_sdk/types.py index 5c46de7f88..f7397adee1 100644 --- a/sentry_sdk/types.py +++ b/sentry_sdk/types.py @@ -12,3 +12,5 @@ if TYPE_CHECKING: from sentry_sdk._types import Event, Hint # noqa: F401 + + __all__ = ["Event", "Hint"] From fe5d54ac55fbd0214fd7c2f703af0ef344cce709 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 27 Mar 2024 15:00:33 +0100 Subject: [PATCH 2/4] ref: Define types at runtime --- sentry_sdk/types.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/types.py b/sentry_sdk/types.py index f7397adee1..f34da51d95 100644 --- a/sentry_sdk/types.py +++ b/sentry_sdk/types.py @@ -12,5 +12,10 @@ if TYPE_CHECKING: from sentry_sdk._types import Event, Hint # noqa: F401 +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"] From 4c33d434b455d2048d804dfab30bdb715dc0eed7 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 27 Mar 2024 15:05:56 +0100 Subject: [PATCH 3/4] Update sentry_sdk/types.py Co-authored-by: anthony sottile <103459774+asottile-sentry@users.noreply.github.com> --- sentry_sdk/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/types.py b/sentry_sdk/types.py index f34da51d95..6cc4ace387 100644 --- a/sentry_sdk/types.py +++ b/sentry_sdk/types.py @@ -18,4 +18,4 @@ Event = None Hint = None -__all__ = ["Event", "Hint"] +__all__ = ("Event", "Hint") From 03a3e2d4003efe33e12bb77cda81af0191922ab7 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 27 Mar 2024 15:06:37 +0100 Subject: [PATCH 4/4] Remove noqa comment --- sentry_sdk/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/types.py b/sentry_sdk/types.py index 6cc4ace387..9a96ed489f 100644 --- a/sentry_sdk/types.py +++ b/sentry_sdk/types.py @@ -11,7 +11,7 @@ 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.