File tree Expand file tree Collapse file tree
sentry_sdk/integrations/pydantic_ai Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import functools
22
33from sentry_sdk .integrations import DidNotEnable , Integration
4- from sentry_sdk .utils import capture_internal_exceptions , package_version
4+ from sentry_sdk .utils import capture_internal_exceptions , parse_version
55
66try :
77 import pydantic_ai # type: ignore # noqa: F401
1010 raise DidNotEnable ("pydantic-ai not installed" )
1111
1212
13+ from importlib .metadata import PackageNotFoundError , version
1314from typing import TYPE_CHECKING
1415
1516from .patches import (
@@ -165,8 +166,16 @@ def setup_once() -> None:
165166 PydanticAIIntegration .are_request_hooks_available = False
166167
167168 # ModelRequestContext.model added in https://github.com/pydantic/pydantic-ai/commit/f1260dfe09907f17688eee1646daf898fc428d4c
168- PYDANTIC_AI_VERSION = package_version ("pydantic-ai" )
169- if PYDANTIC_AI_VERSION is not None and PYDANTIC_AI_VERSION < (
169+ try :
170+ PYDANTIC_AI_VERSION = version ("pydantic-ai-slim" )
171+ except PackageNotFoundError :
172+ return
173+
174+ PYDANTIC_AI_VERSION = parse_version (PYDANTIC_AI_VERSION )
175+ if PYDANTIC_AI_VERSION is None :
176+ return
177+
178+ if PYDANTIC_AI_VERSION < (
170179 1 ,
171180 73 ,
172181 ):
You can’t perform that action at this time.
0 commit comments