Skip to content

Commit ad55e58

Browse files
authored
Re-export imports in __init__.py files (#501)
## Problem My type checker was complaining when I imported anything from `db_control.types`. ## Solution Add all types meant for re-export to `__all__`. ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan N/A
1 parent 96d6045 commit ad55e58

File tree

12 files changed

+165
-6
lines changed

12 files changed

+165
-6
lines changed

pinecone/config/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@
55
from .openapi_configuration import Configuration as OpenApiConfiguration
66
from .pinecone_config import PineconeConfig
77

8+
__all__ = [
9+
"ConfigBuilder",
10+
"Config",
11+
"OpenApiConfiguration",
12+
"PineconeConfig",
13+
]
14+
815
if os.getenv("PINECONE_DEBUG") is not None:
916
logging.getLogger("pinecone").setLevel(level=logging.DEBUG)

pinecone/db_control/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,35 @@
44
from .db_control_asyncio import DBControlAsyncio
55
from .repr_overrides import install_repr_overrides
66

7+
__all__ = [
8+
# from .enums
9+
"CloudProvider",
10+
"AwsRegion",
11+
"GcpRegion",
12+
"AzureRegion",
13+
"DeletionProtection",
14+
"Metric",
15+
"PodIndexEnvironment",
16+
"PodType",
17+
"VectorType",
18+
# from .models
19+
"CollectionDescription",
20+
"PodSpec",
21+
"PodSpecDefinition",
22+
"ServerlessSpec",
23+
"ServerlessSpecDefinition",
24+
"ByocSpec",
25+
"IndexList",
26+
"CollectionList",
27+
"IndexModel",
28+
"IndexEmbed",
29+
"BackupModel",
30+
"BackupList",
31+
"RestoreJobModel",
32+
"RestoreJobList",
33+
# direct imports
34+
"DBControl",
35+
"DBControlAsyncio",
36+
]
37+
738
install_repr_overrides()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
from .index import IndexResourceAsyncio
22
from .collection import CollectionResourceAsyncio
3+
4+
__all__ = ["IndexResourceAsyncio", "CollectionResourceAsyncio"]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
from .index import IndexResource
22
from .collection import CollectionResource
3+
4+
__all__ = ["IndexResource", "CollectionResource"]

pinecone/db_control/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
from .create_index_for_model_embed import CreateIndexForModelEmbedTypedDict
2+
3+
__all__ = ["CreateIndexForModelEmbedTypedDict"]

pinecone/db_data/__init__.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@
2727

2828
from .resources.sync.bulk_import import ImportErrorMode
2929

30+
__all__ = [
31+
"_Index",
32+
"_IndexAsyncio",
33+
"DescribeIndexStatsResponse",
34+
"FetchResponse",
35+
"ImportErrorMode",
36+
"Index",
37+
"IndexClientInstantiationError",
38+
"Inference",
39+
"InferenceInstantiationError",
40+
"MetadataDictionaryExpectedError",
41+
"QueryResponse",
42+
"SearchQuery",
43+
"SearchQueryVector",
44+
"SearchRerank",
45+
"SparseValues",
46+
"SparseValuesDictionaryExpectedError",
47+
"SparseValuesMissingKeysError",
48+
"SparseValuesTypeError",
49+
"UpsertResponse",
50+
"Vector",
51+
"VectorDictionaryExcessKeysError",
52+
"VectorDictionaryMissingKeysError",
53+
"VectorTupleLengthError",
54+
]
3055

3156
import warnings
3257

@@ -41,10 +66,10 @@ def _get_deprecated_import(name, from_module, to_module):
4166
)
4267
# Import from the new location
4368
from pinecone.inference import (
44-
Inference as _Inference,
45-
AsyncioInference as _AsyncioInference,
46-
RerankModel,
47-
EmbedModel,
69+
Inference as _Inference, # noqa: F401
70+
AsyncioInference as _AsyncioInference, # noqa: F401
71+
RerankModel, # noqa: F401
72+
EmbedModel, # noqa: F401
4873
)
4974

5075
return locals()[name]

pinecone/db_data/dataclasses/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@
44
from .search_query import SearchQuery
55
from .search_query_vector import SearchQueryVector
66
from .search_rerank import SearchRerank
7+
8+
__all__ = [
9+
"SparseValues",
10+
"Vector",
11+
"FetchResponse",
12+
"SearchQuery",
13+
"SearchQueryVector",
14+
"SearchRerank",
15+
]

pinecone/db_data/types/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,16 @@
66
from .search_rerank_typed_dict import SearchRerankTypedDict
77
from .search_query_typed_dict import SearchQueryTypedDict
88
from .search_query_vector_typed_dict import SearchQueryVectorTypedDict
9+
10+
__all__ = [
11+
"SparseVectorTypedDict",
12+
"VectorTypedDict",
13+
"VectorMetadataTypedDict",
14+
"VectorTuple",
15+
"VectorTupleWithMetadata",
16+
"FilterTypedDict",
17+
"SearchRerankTypedDict",
18+
"SearchQueryTypedDict",
19+
"SearchQueryVectorTypedDict",
20+
]
21+

pinecone/inference/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,15 @@
44
from .inference_request_builder import RerankModel, EmbedModel
55
from .models import ModelInfo, ModelInfoList, EmbeddingsList, RerankResult
66

7+
__all__ = [
8+
"Inference",
9+
"AsyncioInference",
10+
"RerankModel",
11+
"EmbedModel",
12+
"ModelInfo",
13+
"ModelInfoList",
14+
"EmbeddingsList",
15+
"RerankResult",
16+
]
17+
718
install_repl_overrides()

pinecone/openapi_support/__init__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,45 @@
4747

4848
from .types import PropertyValidationTypedDict
4949
from .cached_class_property import cached_class_property
50+
51+
__all__ = [
52+
"ApiClient",
53+
"Endpoint",
54+
"ExtraOpenApiKwargsTypedDict",
55+
"KwargsWithOpenApiKwargDefaultsTypedDict",
56+
"AsyncioApiClient",
57+
"AsyncioEndpoint",
58+
"Configuration",
59+
"PineconeException",
60+
"PineconeApiAttributeError",
61+
"PineconeApiTypeError",
62+
"PineconeApiValueError",
63+
"PineconeApiKeyError",
64+
"PineconeApiException",
65+
"NotFoundException",
66+
"UnauthorizedException",
67+
"ForbiddenException",
68+
"ServiceException",
69+
"OpenApiModel",
70+
"ModelNormal",
71+
"ModelSimple",
72+
"ModelComposed",
73+
"change_keys_js_to_python",
74+
"convert_js_args_to_python_args",
75+
"validate_get_composed_info",
76+
"cached_property",
77+
"validate_and_convert_types",
78+
"check_allowed_values",
79+
"check_validations",
80+
"file_type",
81+
"none_type",
82+
"Urllib3RestClient",
83+
"AiohttpRestClient",
84+
"RESTResponse",
85+
"OPENAPI_ENDPOINT_PARAMS",
86+
"date",
87+
"datetime",
88+
"parse",
89+
"PropertyValidationTypedDict",
90+
"cached_class_property",
91+
]

0 commit comments

Comments
 (0)