This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import sys
|
||||
from typing import Any, Callable
|
||||
import warnings
|
||||
from typing import Any, Callable, Dict
|
||||
|
||||
from ._internal._validators import import_string
|
||||
from .version import version_short
|
||||
|
||||
MOVED_IN_V2 = {
|
||||
@@ -271,11 +273,7 @@ def getattr_migration(module: str) -> Callable[[str], Any]:
|
||||
The object.
|
||||
"""
|
||||
if name == '__path__':
|
||||
raise AttributeError(f'module {module!r} has no attribute {name!r}')
|
||||
|
||||
import warnings
|
||||
|
||||
from ._internal._validators import import_string
|
||||
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
|
||||
|
||||
import_path = f'{module}:{name}'
|
||||
if import_path in MOVED_IN_V2.keys():
|
||||
@@ -300,9 +298,9 @@ 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}')
|
||||
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
|
||||
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user