|
| 1 | +from typing import TYPE_CHECKING |
| 2 | + |
1 | 3 | from .base_client import BaseClient |
2 | | -from .client import Client |
3 | 4 | from .helpers import ( |
4 | 5 | fill_query_params, |
5 | 6 | sp_endpoint, |
|
36 | 37 | from .processing_status import ProcessingStatus |
37 | 38 | from .reportTypes import ReportType |
38 | 39 | from .feedTypes import FeedType |
39 | | -from sp_api.auth import AccessTokenClient, Credentials |
40 | | -from sp_api.auth.exceptions import AuthorizationError |
41 | 40 | from sp_api.base.inegibility_reasons import IneligibilityReasonList |
42 | 41 | from .marketplaces import AwsEnv |
43 | 42 |
|
| 43 | +if TYPE_CHECKING: |
| 44 | + from .client import Client |
| 45 | + from sp_api.auth import AccessTokenClient, Credentials |
| 46 | + from sp_api.auth.exceptions import AuthorizationError |
| 47 | + |
44 | 48 |
|
45 | 49 | __all__ = [ |
46 | 50 | "Credentials", |
|
92 | 96 | # Backward-compatibility aliases for docs and legacy imports. |
93 | 97 | FeedTypes = FeedType |
94 | 98 | FulfillmentChannels = FulfillmentChannel |
| 99 | + |
| 100 | + |
| 101 | +def __getattr__(name): |
| 102 | + if name == "Client": |
| 103 | + from .client import Client |
| 104 | + |
| 105 | + globals()[name] = Client |
| 106 | + return Client |
| 107 | + if name in {"AccessTokenClient", "Credentials"}: |
| 108 | + from sp_api.auth import AccessTokenClient, Credentials |
| 109 | + |
| 110 | + exports = {"AccessTokenClient": AccessTokenClient, "Credentials": Credentials} |
| 111 | + globals()[name] = exports[name] |
| 112 | + return exports[name] |
| 113 | + if name == "AuthorizationError": |
| 114 | + from sp_api.auth.exceptions import AuthorizationError |
| 115 | + |
| 116 | + globals()[name] = AuthorizationError |
| 117 | + return AuthorizationError |
| 118 | + raise AttributeError(f"module '{__name__}' has no attribute '{name}'") |
0 commit comments