|
2 | 2 |
|
3 | 3 | # isort: skip_file |
4 | 4 |
|
5 | | -from .types import ( |
6 | | - ColumnRedactions, |
7 | | - DeleteResponse, |
8 | | - DeleteResponseObject, |
9 | | - DetokenizeResponse, |
10 | | - DetokenizeResponseObject, |
11 | | - ErrorResponse, |
12 | | - ErrorResponseError, |
13 | | - ExecuteQueryRecordResponse, |
14 | | - ExecuteQueryResponse, |
15 | | - ExecuteQueryResponseMetadata, |
16 | | - GetRequestData, |
17 | | - GetResponse, |
18 | | - GetTokensFromValuesRequestObject, |
19 | | - GetTokensFromValuesResponse, |
20 | | - GoogleProtobufValue, |
21 | | - HttpCode, |
22 | | - InsertRecordData, |
23 | | - InsertResponse, |
24 | | - RecordResponseObject, |
25 | | - TokenGroupRedactions, |
26 | | - TokenizeResponseObject, |
27 | | - UniqueValue, |
28 | | - UpdateRecordData, |
29 | | - UpdateResponse, |
30 | | - Upsert, |
31 | | - UpsertUpdateType, |
32 | | -) |
33 | | -from .errors import ( |
34 | | - BadRequestError, |
35 | | - ForbiddenError, |
36 | | - InternalServerError, |
37 | | - NotFoundError, |
38 | | - TooManyRequestsError, |
39 | | - UnauthorizedError, |
40 | | -) |
41 | | -from . import query, records, tokens |
42 | | -from .client import AsyncSkyflowAuth, SkyflowAuth |
43 | | -from .environment import SkyflowAuthEnvironment |
44 | | -from .version import __version__ |
| 5 | +import typing |
| 6 | +from importlib import import_module |
| 7 | + |
| 8 | +if typing.TYPE_CHECKING: |
| 9 | + from .types import ( |
| 10 | + ColumnRedactions, |
| 11 | + DeleteResponse, |
| 12 | + DeleteResponseObject, |
| 13 | + DetokenizeResponse, |
| 14 | + DetokenizeResponseObject, |
| 15 | + ErrorResponse, |
| 16 | + ErrorResponseError, |
| 17 | + ExecuteQueryRecordResponse, |
| 18 | + ExecuteQueryResponse, |
| 19 | + ExecuteQueryResponseMetadata, |
| 20 | + GetRequestData, |
| 21 | + GetResponse, |
| 22 | + GetTokensFromValuesRequestObject, |
| 23 | + GetTokensFromValuesResponse, |
| 24 | + GoogleProtobufValue, |
| 25 | + HttpCode, |
| 26 | + InsertRecordData, |
| 27 | + InsertResponse, |
| 28 | + RecordResponseObject, |
| 29 | + TokenGroupRedactions, |
| 30 | + TokenizeResponseObject, |
| 31 | + UniqueValue, |
| 32 | + UpdateRecordData, |
| 33 | + UpdateResponse, |
| 34 | + Upsert, |
| 35 | + UpsertUpdateType, |
| 36 | + ) |
| 37 | + from .errors import ( |
| 38 | + BadRequestError, |
| 39 | + ForbiddenError, |
| 40 | + InternalServerError, |
| 41 | + NotFoundError, |
| 42 | + TooManyRequestsError, |
| 43 | + UnauthorizedError, |
| 44 | + ) |
| 45 | + from . import query, records, tokens |
| 46 | + from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient |
| 47 | + from .client import AsyncSkyflowAuth, SkyflowAuth |
| 48 | + from .environment import SkyflowAuthEnvironment |
| 49 | + from .version import __version__ |
| 50 | +_dynamic_imports: typing.Dict[str, str] = { |
| 51 | + "AsyncSkyflowAuth": ".client", |
| 52 | + "BadRequestError": ".errors", |
| 53 | + "ColumnRedactions": ".types", |
| 54 | + "DefaultAioHttpClient": "._default_clients", |
| 55 | + "DefaultAsyncHttpxClient": "._default_clients", |
| 56 | + "DeleteResponse": ".types", |
| 57 | + "DeleteResponseObject": ".types", |
| 58 | + "DetokenizeResponse": ".types", |
| 59 | + "DetokenizeResponseObject": ".types", |
| 60 | + "ErrorResponse": ".types", |
| 61 | + "ErrorResponseError": ".types", |
| 62 | + "ExecuteQueryRecordResponse": ".types", |
| 63 | + "ExecuteQueryResponse": ".types", |
| 64 | + "ExecuteQueryResponseMetadata": ".types", |
| 65 | + "ForbiddenError": ".errors", |
| 66 | + "GetRequestData": ".types", |
| 67 | + "GetResponse": ".types", |
| 68 | + "GetTokensFromValuesRequestObject": ".types", |
| 69 | + "GetTokensFromValuesResponse": ".types", |
| 70 | + "GoogleProtobufValue": ".types", |
| 71 | + "HttpCode": ".types", |
| 72 | + "InsertRecordData": ".types", |
| 73 | + "InsertResponse": ".types", |
| 74 | + "InternalServerError": ".errors", |
| 75 | + "NotFoundError": ".errors", |
| 76 | + "RecordResponseObject": ".types", |
| 77 | + "SkyflowAuth": ".client", |
| 78 | + "SkyflowAuthEnvironment": ".environment", |
| 79 | + "TokenGroupRedactions": ".types", |
| 80 | + "TokenizeResponseObject": ".types", |
| 81 | + "TooManyRequestsError": ".errors", |
| 82 | + "UnauthorizedError": ".errors", |
| 83 | + "UniqueValue": ".types", |
| 84 | + "UpdateRecordData": ".types", |
| 85 | + "UpdateResponse": ".types", |
| 86 | + "Upsert": ".types", |
| 87 | + "UpsertUpdateType": ".types", |
| 88 | + "__version__": ".version", |
| 89 | + "query": ".query", |
| 90 | + "records": ".records", |
| 91 | + "tokens": ".tokens", |
| 92 | +} |
| 93 | + |
| 94 | + |
| 95 | +def __getattr__(attr_name: str) -> typing.Any: |
| 96 | + module_name = _dynamic_imports.get(attr_name) |
| 97 | + if module_name is None: |
| 98 | + raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}") |
| 99 | + try: |
| 100 | + module = import_module(module_name, __package__) |
| 101 | + if module_name == f".{attr_name}": |
| 102 | + return module |
| 103 | + else: |
| 104 | + return getattr(module, attr_name) |
| 105 | + except ImportError as e: |
| 106 | + raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e |
| 107 | + except AttributeError as e: |
| 108 | + raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e |
| 109 | + |
| 110 | + |
| 111 | +def __dir__(): |
| 112 | + lazy_attrs = list(_dynamic_imports.keys()) |
| 113 | + return sorted(lazy_attrs) |
| 114 | + |
45 | 115 |
|
46 | 116 | __all__ = [ |
47 | 117 | "AsyncSkyflowAuth", |
48 | 118 | "BadRequestError", |
49 | 119 | "ColumnRedactions", |
| 120 | + "DefaultAioHttpClient", |
| 121 | + "DefaultAsyncHttpxClient", |
50 | 122 | "DeleteResponse", |
51 | 123 | "DeleteResponseObject", |
52 | 124 | "DetokenizeResponse", |
|
0 commit comments