File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 4040except ImportError :
4141 yaml = None
4242
43- has_pydantic_settings = True
43+ has_pydantic_settings = False
4444cdef bint pydantic_v1 = False
45+ cdef object PydanticSettings = None
4546cdef str pydantic_module = " pydantic_settings"
4647cdef str pydantic_extra = " pydantic2"
4748
4849try :
4950 from pydantic_settings import BaseSettings as PydanticSettings
5051except ImportError :
5152 try :
52- # pydantic-settings requires pydantic v2,
53- # so it is safe to assume that we're dealing with v1:
54- from pydantic import BaseSettings as PydanticSettings
55- pydantic_v1 = True
56- pydantic_module = " pydantic"
57- pydantic_extra = " pydantic"
53+ import pydantic
5854 except ImportError :
59- # if it is present, ofc
60- has_pydantic_settings = False
55+ pass
56+ else :
57+ # Avoid triggering deprecation warning in v2+
58+ if pydantic.VERSION.startswith(" 1." ):
59+ PydanticSettings = pydantic.BaseSettings
60+ pydantic_v1 = True
61+ pydantic_module = " pydantic"
62+ pydantic_extra = " pydantic"
63+ has_pydantic_settings = True
64+ else :
65+ has_pydantic_settings = True
6166
6267
6368from .errors import (
You can’t perform that action at this time.
0 commit comments