Skip to content

Commit 48db04e

Browse files
add black defaults in pyproject.toml, undo a bunch of the <100 line breaks
1 parent 107a1cd commit 48db04e

9 files changed

Lines changed: 48 additions & 145 deletions

File tree

pinecone/__init__.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
.. include:: ../pdoc/README.md
33
"""
44

5-
from .deprecated_plugins import (
6-
check_for_deprecated_plugins as _check_for_deprecated_plugins,
7-
)
5+
from .deprecated_plugins import check_for_deprecated_plugins as _check_for_deprecated_plugins
86
from .deprecation_warnings import *
97
from .pinecone import Pinecone
108
from .pinecone_asyncio import PineconeAsyncio
@@ -48,10 +46,7 @@
4846
"SearchRerank": ("pinecone.db_data.dataclasses", "SearchRerank"),
4947
"FetchResponse": ("pinecone.db_data.dataclasses", "FetchResponse"),
5048
"DeleteRequest": ("pinecone.db_data.models", "DeleteRequest"),
51-
"DescribeIndexStatsRequest": (
52-
"pinecone.db_data.models",
53-
"DescribeIndexStatsRequest",
54-
),
49+
"DescribeIndexStatsRequest": ("pinecone.db_data.models", "DescribeIndexStatsRequest"),
5550
"DescribeIndexStatsResponse": ("pinecone.db_data.models", "IndexDescription"),
5651
"RpcStatus": ("pinecone.db_data.models", "RpcStatus"),
5752
"ScoredVector": ("pinecone.db_data.models", "ScoredVector"),
@@ -60,14 +55,8 @@
6055
"QueryResponse": ("pinecone.db_data.models", "QueryResponse"),
6156
"UpsertResponse": ("pinecone.db_data.models", "UpsertResponse"),
6257
"UpdateRequest": ("pinecone.db_data.models", "UpdateRequest"),
63-
"NamespaceDescription": (
64-
"pinecone.core.openapi.db_data.models",
65-
"NamespaceDescription",
66-
),
67-
"ImportErrorMode": (
68-
"pinecone.db_data.resources.sync.bulk_import",
69-
"ImportErrorMode",
70-
),
58+
"NamespaceDescription": ("pinecone.core.openapi.db_data.models", "NamespaceDescription"),
59+
"ImportErrorMode": ("pinecone.db_data.resources.sync.bulk_import", "ImportErrorMode"),
7160
"VectorDictionaryMissingKeysError": (
7261
"pinecone.db_data.errors",
7362
"VectorDictionaryMissingKeysError",
@@ -78,10 +67,7 @@
7867
),
7968
"VectorTupleLengthError": ("pinecone.db_data.errors", "VectorTupleLengthError"),
8069
"SparseValuesTypeError": ("pinecone.db_data.errors", "SparseValuesTypeError"),
81-
"SparseValuesMissingKeysError": (
82-
"pinecone.db_data.errors",
83-
"SparseValuesMissingKeysError",
84-
),
70+
"SparseValuesMissingKeysError": ("pinecone.db_data.errors", "SparseValuesMissingKeysError"),
8571
"SparseValuesDictionaryExpectedError": (
8672
"pinecone.db_data.errors",
8773
"SparseValuesDictionaryExpectedError",
@@ -104,10 +90,7 @@
10490
"IndexEmbed": ("pinecone.db_control.models", "IndexEmbed"),
10591
"ByocSpec": ("pinecone.db_control.models", "ByocSpec"),
10692
"ServerlessSpec": ("pinecone.db_control.models", "ServerlessSpec"),
107-
"ServerlessSpecDefinition": (
108-
"pinecone.db_control.models",
109-
"ServerlessSpecDefinition",
110-
),
93+
"ServerlessSpecDefinition": ("pinecone.db_control.models", "ServerlessSpecDefinition"),
11194
"PodSpec": ("pinecone.db_control.models", "PodSpec"),
11295
"PodSpecDefinition": ("pinecone.db_control.models", "PodSpecDefinition"),
11396
"PodType": ("pinecone.db_control.enums", "PodType"),

pinecone/db_control/request_factory.py

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,15 @@
44

55
from pinecone.utils import parse_non_empty_args, convert_enum_to_string
66

7-
from pinecone.core.openapi.db_control.model.create_collection_request import (
8-
CreateCollectionRequest,
9-
)
7+
from pinecone.core.openapi.db_control.model.create_collection_request import CreateCollectionRequest
108
from pinecone.core.openapi.db_control.model.create_index_for_model_request import (
119
CreateIndexForModelRequest,
1210
)
1311
from pinecone.core.openapi.db_control.model.create_index_for_model_request_embed import (
1412
CreateIndexForModelRequestEmbed,
1513
)
16-
from pinecone.core.openapi.db_control.model.create_index_request import (
17-
CreateIndexRequest,
18-
)
19-
from pinecone.core.openapi.db_control.model.configure_index_request import (
20-
ConfigureIndexRequest,
21-
)
14+
from pinecone.core.openapi.db_control.model.create_index_request import CreateIndexRequest
15+
from pinecone.core.openapi.db_control.model.configure_index_request import ConfigureIndexRequest
2216
from pinecone.core.openapi.db_control.model.configure_index_request_spec import (
2317
ConfigureIndexRequestSpec,
2418
)
@@ -38,19 +32,11 @@
3832
)
3933
from pinecone.core.openapi.db_control.model.byoc_spec import ByocSpec as ByocSpecModel
4034
from pinecone.core.openapi.db_control.model.pod_spec import PodSpec as PodSpecModel
41-
from pinecone.core.openapi.db_control.model.pod_spec_metadata_config import (
42-
PodSpecMetadataConfig,
43-
)
35+
from pinecone.core.openapi.db_control.model.pod_spec_metadata_config import PodSpecMetadataConfig
4436
from pinecone.core.openapi.db_control.model.create_index_from_backup_request import (
4537
CreateIndexFromBackupRequest,
4638
)
47-
from pinecone.db_control.models import (
48-
ServerlessSpec,
49-
PodSpec,
50-
ByocSpec,
51-
IndexModel,
52-
IndexEmbed,
53-
)
39+
from pinecone.db_control.models import ServerlessSpec, PodSpec, ByocSpec, IndexModel, IndexEmbed
5440

5541
from pinecone.db_control.enums import (
5642
Metric,
@@ -91,30 +77,18 @@ def __parse_deletion_protection(
9177
if deletion_protection in ["enabled", "disabled"]:
9278
return DeletionProtectionModel(deletion_protection)
9379
else:
94-
raise ValueError(
95-
"deletion_protection must be either 'enabled' or 'disabled'"
96-
)
80+
raise ValueError("deletion_protection must be either 'enabled' or 'disabled'")
9781

9882
@staticmethod
99-
def __parse_index_spec(
100-
spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec],
101-
) -> IndexSpec:
83+
def __parse_index_spec(spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec]) -> IndexSpec:
10284
if isinstance(spec, dict):
10385
if "serverless" in spec:
104-
spec["serverless"]["cloud"] = convert_enum_to_string(
105-
spec["serverless"]["cloud"]
106-
)
107-
spec["serverless"]["region"] = convert_enum_to_string(
108-
spec["serverless"]["region"]
109-
)
86+
spec["serverless"]["cloud"] = convert_enum_to_string(spec["serverless"]["cloud"])
87+
spec["serverless"]["region"] = convert_enum_to_string(spec["serverless"]["region"])
11088

111-
index_spec = IndexSpec(
112-
serverless=ServerlessSpecModel(**spec["serverless"])
113-
)
89+
index_spec = IndexSpec(serverless=ServerlessSpecModel(**spec["serverless"]))
11490
elif "pod" in spec:
115-
spec["pod"]["environment"] = convert_enum_to_string(
116-
spec["pod"]["environment"]
117-
)
91+
spec["pod"]["environment"] = convert_enum_to_string(spec["pod"]["environment"])
11892
args_dict = parse_non_empty_args(
11993
[
12094
("environment", spec["pod"].get("environment")),
@@ -133,9 +107,7 @@ def __parse_index_spec(
133107
elif "byoc" in spec:
134108
index_spec = IndexSpec(byoc=ByocSpecModel(**spec["byoc"]))
135109
else:
136-
raise ValueError(
137-
"spec must contain either 'serverless', 'pod', or 'byoc' key"
138-
)
110+
raise ValueError("spec must contain either 'serverless', 'pod', or 'byoc' key")
139111
elif isinstance(spec, ServerlessSpec):
140112
index_spec = IndexSpec(
141113
serverless=ServerlessSpecModel(cloud=spec.cloud, region=spec.region)
@@ -155,17 +127,13 @@ def __parse_index_spec(
155127
)
156128

157129
index_spec = IndexSpec(
158-
pod=PodSpecModel(
159-
environment=spec.environment, pod_type=spec.pod_type, **args_dict
160-
)
130+
pod=PodSpecModel(environment=spec.environment, pod_type=spec.pod_type, **args_dict)
161131
)
162132
elif isinstance(spec, ByocSpec):
163133
args_dict = parse_non_empty_args([("environment", spec.environment)])
164134
index_spec = IndexSpec(byoc=ByocSpecModel(**args_dict))
165135
else:
166-
raise TypeError(
167-
"spec must be of type dict, ServerlessSpec, PodSpec, or ByocSpec"
168-
)
136+
raise TypeError("spec must be of type dict, ServerlessSpec, PodSpec, or ByocSpec")
169137

170138
return index_spec
171139

@@ -175,9 +143,7 @@ def create_index_request(
175143
spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec],
176144
dimension: Optional[int] = None,
177145
metric: Optional[Union[Metric, str]] = Metric.COSINE,
178-
deletion_protection: Optional[
179-
Union[DeletionProtection, str]
180-
] = DeletionProtection.DISABLED,
146+
deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED,
181147
vector_type: Optional[Union[VectorType, str]] = VectorType.DENSE,
182148
tags: Optional[Dict[str, str]] = None,
183149
) -> CreateIndexRequest:
@@ -186,9 +152,7 @@ def create_index_request(
186152
if vector_type is not None:
187153
vector_type = convert_enum_to_string(vector_type)
188154
if deletion_protection is not None:
189-
dp = PineconeDBControlRequestFactory.__parse_deletion_protection(
190-
deletion_protection
191-
)
155+
dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection)
192156
else:
193157
dp = None
194158

@@ -219,16 +183,12 @@ def create_index_for_model_request(
219183
region: Union[AwsRegion, GcpRegion, AzureRegion, str],
220184
embed: Union[IndexEmbed, CreateIndexForModelEmbedTypedDict],
221185
tags: Optional[Dict[str, str]] = None,
222-
deletion_protection: Optional[
223-
Union[DeletionProtection, str]
224-
] = DeletionProtection.DISABLED,
186+
deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED,
225187
) -> CreateIndexForModelRequest:
226188
cloud = convert_enum_to_string(cloud)
227189
region = convert_enum_to_string(region)
228190
if deletion_protection is not None:
229-
dp = PineconeDBControlRequestFactory.__parse_deletion_protection(
230-
deletion_protection
231-
)
191+
dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection)
232192
else:
233193
dp = None
234194
tags_obj = PineconeDBControlRequestFactory.__parse_tags(tags)
@@ -265,23 +225,17 @@ def create_index_for_model_request(
265225
@staticmethod
266226
def create_index_from_backup_request(
267227
name: str,
268-
deletion_protection: Optional[
269-
Union[DeletionProtection, str]
270-
] = DeletionProtection.DISABLED,
228+
deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED,
271229
tags: Optional[Dict[str, str]] = None,
272230
) -> CreateIndexFromBackupRequest:
273231
if deletion_protection is not None:
274-
dp = PineconeDBControlRequestFactory.__parse_deletion_protection(
275-
deletion_protection
276-
)
232+
dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection)
277233
else:
278234
dp = None
279235

280236
tags_obj = PineconeDBControlRequestFactory.__parse_tags(tags)
281237

282-
return CreateIndexFromBackupRequest(
283-
name=name, deletion_protection=dp, tags=tags_obj
284-
)
238+
return CreateIndexFromBackupRequest(name=name, deletion_protection=dp, tags=tags_obj)
285239

286240
@staticmethod
287241
def configure_index_request(
@@ -299,9 +253,7 @@ def configure_index_request(
299253
elif deletion_protection in ["enabled", "disabled"]:
300254
dp = DeletionProtectionModel(deletion_protection)
301255
else:
302-
raise ValueError(
303-
"deletion_protection must be either 'enabled' or 'disabled'"
304-
)
256+
raise ValueError("deletion_protection must be either 'enabled' or 'disabled'")
305257

306258
fetched_tags = description.tags
307259
if fetched_tags is None:
@@ -329,9 +281,7 @@ def configure_index_request(
329281

330282
spec = None
331283
if pod_config_args:
332-
spec = ConfigureIndexRequestSpec(
333-
pod=ConfigureIndexRequestSpecPod(**pod_config_args)
334-
)
284+
spec = ConfigureIndexRequestSpec(pod=ConfigureIndexRequestSpecPod(**pod_config_args))
335285

336286
args_dict = parse_non_empty_args(
337287
[

pinecone/db_control/resources/asyncio/index.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import asyncio
3-
from typing import Optional, Dict, Union
3+
from typing import Optional, Dict, Union, Any
44

55

66
from pinecone.db_control.models import (
@@ -47,9 +47,7 @@ async def create(
4747
dimension: Optional[int] = None,
4848
metric: Optional[Union[Metric, str]] = Metric.COSINE,
4949
timeout: Optional[int] = None,
50-
deletion_protection: Optional[
51-
Union[DeletionProtection, str]
52-
] = DeletionProtection.DISABLED,
50+
deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED,
5351
vector_type: Optional[Union[VectorType, str]] = VectorType.DENSE,
5452
tags: Optional[Dict[str, str]] = None,
5553
) -> IndexModel:
@@ -77,9 +75,7 @@ async def create_for_model(
7775
region: Union[AwsRegion, GcpRegion, AzureRegion, str],
7876
embed: Union[IndexEmbed, CreateIndexForModelEmbedTypedDict],
7977
tags: Optional[Dict[str, str]] = None,
80-
deletion_protection: Optional[
81-
Union[DeletionProtection, str]
82-
] = DeletionProtection.DISABLED,
78+
deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED,
8379
timeout: Optional[int] = None,
8480
) -> IndexModel:
8581
req = PineconeDBControlRequestFactory.create_index_for_model_request(
@@ -102,9 +98,7 @@ async def create_from_backup(
10298
*,
10399
name: str,
104100
backup_id: str,
105-
deletion_protection: Optional[
106-
Union[DeletionProtection, str]
107-
] = DeletionProtection.DISABLED,
101+
deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED,
108102
tags: Optional[Dict[str, str]] = None,
109103
timeout: Optional[int] = None,
110104
) -> IndexModel:
@@ -116,9 +110,7 @@ async def create_from_backup(
116110
)
117111
return await self.__poll_describe_index_until_ready(name, timeout)
118112

119-
async def __poll_describe_index_until_ready(
120-
self, name: str, timeout: Optional[int] = None
121-
):
113+
async def __poll_describe_index_until_ready(self, name: str, timeout: Optional[int] = None):
122114
total_wait_time = 0
123115
while True:
124116
description = await self.describe(name=name)

pinecone/db_control/resources/sync/index.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
from pinecone.db_control.index_host_store import IndexHostStore
66

7-
from pinecone.db_control.models import (
8-
IndexModel,
9-
IndexList,
10-
IndexEmbed,
11-
)
7+
from pinecone.db_control.models import IndexModel, IndexList, IndexEmbed
128
from pinecone.utils import docslinks, require_kwargs, PluginAware
139

1410
from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict
@@ -149,9 +145,7 @@ def create_from_backup(
149145
return self.describe(name=name)
150146
return self.__poll_describe_index_until_ready(name, timeout)
151147

152-
def __poll_describe_index_until_ready(
153-
self, name: str, timeout: Optional[int] = None
154-
):
148+
def __poll_describe_index_until_ready(self, name: str, timeout: Optional[int] = None):
155149
total_wait_time = 0
156150
while True:
157151
description = self.describe(name=name)

pinecone/legacy_pinecone_interface.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
GcpRegion,
2727
AzureRegion,
2828
)
29-
from pinecone.db_control.types import (
30-
CreateIndexForModelEmbedTypedDict,
31-
ConfigureIndexEmbed,
32-
)
29+
from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict, ConfigureIndexEmbed
3330

3431

3532
class LegacyPineconeDBControlInterface(ABC):

pinecone/pinecone.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
from pinecone.db_data import _Index as Index, _IndexAsyncio as IndexAsyncio
1919
from pinecone.db_control.index_host_store import IndexHostStore
2020
from pinecone.core.openapi.db_control.api.manage_indexes_api import ManageIndexesApi
21-
from pinecone.db_control.types import (
22-
CreateIndexForModelEmbedTypedDict,
23-
ConfigureIndexEmbed,
24-
)
21+
from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict, ConfigureIndexEmbed
2522
from pinecone.db_control.enums import (
2623
Metric,
2724
VectorType,
@@ -228,9 +225,7 @@ def __init__(
228225
)
229226
""" :meta private: """
230227

231-
self._openapi_config = ConfigBuilder.build_openapi_config(
232-
self._config, **kwargs
233-
)
228+
self._openapi_config = ConfigBuilder.build_openapi_config(self._config, **kwargs)
234229
""" :meta private: """
235230

236231
if pool_threads is None:

0 commit comments

Comments
 (0)