Skip to content

Commit 42b0709

Browse files
authored
Merge pull request #1985 from saleweaver/fix_asyncio
fix asyncio import error
2 parents b53630c + a9baa7d commit 42b0709

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

sp_api/base/__init__.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from typing import TYPE_CHECKING
2+
13
from .base_client import BaseClient
2-
from .client import Client
34
from .helpers import (
45
fill_query_params,
56
sp_endpoint,
@@ -36,11 +37,14 @@
3637
from .processing_status import ProcessingStatus
3738
from .reportTypes import ReportType
3839
from .feedTypes import FeedType
39-
from sp_api.auth import AccessTokenClient, Credentials
40-
from sp_api.auth.exceptions import AuthorizationError
4140
from sp_api.base.inegibility_reasons import IneligibilityReasonList
4241
from .marketplaces import AwsEnv
4342

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+
4448

4549
__all__ = [
4650
"Credentials",
@@ -92,3 +96,23 @@
9296
# Backward-compatibility aliases for docs and legacy imports.
9397
FeedTypes = FeedType
9498
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

Comments
 (0)