This commit is contained in:
Iliyan Angelov
2025-12-06 03:27:35 +02:00
parent 7667eb5eda
commit 5a8ca3c475
2211 changed files with 28086 additions and 37066 deletions

View File

@@ -1,7 +1,5 @@
import sys
from typing import Any, Callable
from pydantic.warnings import PydanticDeprecatedSince20
from typing import Any, Callable, Dict
from .version import version_short
@@ -282,11 +280,7 @@ def getattr_migration(module: str) -> Callable[[str], Any]:
import_path = f'{module}:{name}'
if import_path in MOVED_IN_V2.keys():
new_location = MOVED_IN_V2[import_path]
warnings.warn(
f'`{import_path}` has been moved to `{new_location}`.',
category=PydanticDeprecatedSince20,
stacklevel=2,
)
warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
return import_string(MOVED_IN_V2[import_path])
if import_path in DEPRECATED_MOVED_IN_V2:
# skip the warning here because a deprecation warning will be raised elsewhere
@@ -295,9 +289,7 @@ def getattr_migration(module: str) -> Callable[[str], Any]:
new_location = REDIRECT_TO_V1[import_path]
warnings.warn(
f'`{import_path}` has been removed. We are importing from `{new_location}` instead.'
'See the migration guide for more details: https://docs.pydantic.dev/latest/migration/',
category=PydanticDeprecatedSince20,
stacklevel=2,
'See the migration guide for more details: https://docs.pydantic.dev/latest/migration/'
)
return import_string(REDIRECT_TO_V1[import_path])
if import_path == 'pydantic:BaseSettings':
@@ -308,7 +300,7 @@ def getattr_migration(module: str) -> Callable[[str], Any]:
)
if import_path in REMOVED_IN_V2:
raise PydanticImportError(f'`{import_path}` has been removed in V2.')
globals: dict[str, Any] = sys.modules[module].__dict__
globals: Dict[str, Any] = sys.modules[module].__dict__
if name in globals:
return globals[name]
raise AttributeError(f'module {module!r} has no attribute {name!r}')