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