From 9492ce6749b94fd8b864c892bb1f79a02286dcba Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 17 Dec 2025 13:28:17 +0100 Subject: [PATCH 1/2] fix(trytond): Gate third-party imports --- sentry_sdk/integrations/trytond.py | 9 ++++++--- tests/test_shadowed_module.py | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sentry_sdk/integrations/trytond.py b/sentry_sdk/integrations/trytond.py index 03e71734da..4cf32fde76 100644 --- a/sentry_sdk/integrations/trytond.py +++ b/sentry_sdk/integrations/trytond.py @@ -2,10 +2,13 @@ from sentry_sdk.integrations import Integration from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware from sentry_sdk.utils import ensure_integration_enabled, event_from_exception +from sentry_sdk.integrations import DidNotEnable -from trytond.exceptions import TrytonException # type: ignore -from trytond.wsgi import app # type: ignore - +try: + from trytond.exceptions import TrytonException # type: ignore + from trytond.wsgi import app # type: ignore +except ImportError: + raise DidNotEnable("Trytond not installed.") # TODO: trytond-worker, trytond-cron and trytond-admin intergations diff --git a/tests/test_shadowed_module.py b/tests/test_shadowed_module.py index e1171dd103..34bb7917f4 100644 --- a/tests/test_shadowed_module.py +++ b/tests/test_shadowed_module.py @@ -35,7 +35,6 @@ def pytest_generate_tests(metafunc): "opentelemetry", "pure_eval", "ray", - "trytond", "typer", }, ) From 1fabca497dda1fcda770b9b2b9e8288d4ddab0b8 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 17 Dec 2025 13:39:46 +0100 Subject: [PATCH 2/2] clearer message --- sentry_sdk/integrations/trytond.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry_sdk/integrations/trytond.py b/sentry_sdk/integrations/trytond.py index 4cf32fde76..382e7385e2 100644 --- a/sentry_sdk/integrations/trytond.py +++ b/sentry_sdk/integrations/trytond.py @@ -8,7 +8,7 @@ from trytond.exceptions import TrytonException # type: ignore from trytond.wsgi import app # type: ignore except ImportError: - raise DidNotEnable("Trytond not installed.") + raise DidNotEnable("Trytond is not installed.") # TODO: trytond-worker, trytond-cron and trytond-admin intergations