| 1 |
import importlib |
| 2 |
import sys |
| 3 |
import typing as t |
| 4 |
|
| 5 |
__all__ = ( |
| 6 |
"BookmarkCreateDocument", |
| 7 |
"BookmarkUpdateDocument", |
| 8 |
"TransferClientV2", |
| 9 |
"TunnelCreateDocument", |
| 10 |
"TunnelUpdateDocument", |
| 11 |
) |
| 12 |
|
| 13 |
|
| 14 |
# imports from `globus_sdk.experimental.transfer_v2` are done lazily to ensure |
| 15 |
# that we do not eagerly import `requests` when attempting to use SDK |
| 16 |
# components which do not need it |
| 17 |
if t.TYPE_CHECKING: |
| 18 |
from .transfer_v2 import ( |
| 19 |
BookmarkCreateDocument, |
| 20 |
BookmarkUpdateDocument, |
| 21 |
TransferClientV2, |
| 22 |
TunnelCreateDocument, |
| 23 |
TunnelUpdateDocument, |
| 24 |
) |
| 25 |
else: |
| 26 |
_LAZY_IMPORT_TABLE = { |
| 27 |
"transfer_v2": { |
| 28 |
"BookmarkCreateDocument", |
| 29 |
"BookmarkUpdateDocument", |
| 30 |
"TransferClientV2", |
| 31 |
"TunnelCreateDocument", |
| 32 |
"TunnelUpdateDocument", |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
def __getattr__(name: str) -> t.Any: |
| 37 |
for modname, items in _LAZY_IMPORT_TABLE.items(): |
| 38 |
if name in items: |
| 39 |
mod = importlib.import_module("." + modname, __name__) |
| 40 |
value = getattr(mod, name) |
| 41 |
setattr(sys.modules[__name__], name, value) |
| 42 |
return value |
| 43 |
|
| 44 |
raise AttributeError(f"module {__name__} has no attribute {name}") |