| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import typing |
| 6 |
from importlib import import_module |
| 7 |
|
| 8 |
if typing.TYPE_CHECKING: |
| 9 |
from .errors import ErrorsGetResponse |
| 10 |
from . import errors, users_exports, users_imports, verification_email |
| 11 |
_dynamic_imports: typing.Dict[str, str] = { |
| 12 |
"ErrorsGetResponse": ".errors", |
| 13 |
"errors": ".errors", |
| 14 |
"users_exports": ".users_exports", |
| 15 |
"users_imports": ".users_imports", |
| 16 |
"verification_email": ".verification_email", |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
def __getattr__(attr_name: str) -> typing.Any: |
| 21 |
module_name = _dynamic_imports.get(attr_name) |
| 22 |
if module_name is None: |
| 23 |
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") |
| 24 |
try: |
| 25 |
module = import_module(module_name, __package__) |
| 26 |
if module_name == f".{attr_name}": |
| 27 |
return module |
| 28 |
else: |
| 29 |
return getattr(module, attr_name) |
| 30 |
except ImportError as e: |
| 31 |
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e |
| 32 |
except AttributeError as e: |
| 33 |
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e |
| 34 |
|
| 35 |
|
| 36 |
def __dir__(): |
| 37 |
lazy_attrs = list(_dynamic_imports.keys()) |
| 38 |
return sorted(lazy_attrs) |
| 39 |
|
| 40 |
|
| 41 |
__all__ = ["ErrorsGetResponse", "errors", "users_exports", "users_imports", "verification_email"] |