Skip to content

Commit 1de73f8

Browse files
committed
Lint fixes for tests
1 parent 594ab51 commit 1de73f8

File tree

75 files changed

+933
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+933
-658
lines changed

codegen/build-oas.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ generate_client() {
7171

7272
oas_file="codegen/apis/_build/${version}/${module_name}_${version}.oas.yaml"
7373
package_name="pinecone.${py_module_name}.openapi.${module_name}"
74-
74+
7575
verify_file_exists $oas_file
7676
verify_directory_exists $template_dir
7777

@@ -106,9 +106,9 @@ extract_shared_classes() {
106106
# Define the list of shared source files
107107
sharedFiles=(
108108
"api_client"
109-
"configuration"
110-
"exceptions"
111-
"model_utils"
109+
"configuration"
110+
"exceptions"
111+
"model_utils"
112112
"rest"
113113
)
114114

@@ -127,7 +127,7 @@ extract_shared_classes() {
127127
done
128128
done
129129

130-
# Remove the docstring headers that aren't really correct in the
130+
# Remove the docstring headers that aren't really correct in the
131131
# context of this new shared package structure
132132
find "$target_directory" -name "*.py" -print0 | xargs -0 -I {} sh -c 'sed -i "" "/^\"\"\"/,/^\"\"\"/d" "{}"'
133133

@@ -166,4 +166,4 @@ done
166166
extract_shared_classes
167167

168168
# Format generated files
169-
poetry run black "${destination}"
169+
poetry run ruff format "${destination}"

pinecone/config/config.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
from pinecone.exceptions.exceptions import PineconeConfigurationError
55
from pinecone.config.openapi import OpenApiConfigFactory
6-
from pinecone.core.openapi.shared.configuration import (
7-
Configuration as OpenApiConfiguration,
8-
)
6+
from pinecone.core.openapi.shared.configuration import Configuration as OpenApiConfiguration
97
from pinecone.utils import normalize_host
108
from pinecone.utils.constants import SOURCE_TAG
119

@@ -72,15 +70,11 @@ def build(
7270

7371
@staticmethod
7472
def build_openapi_config(
75-
config: Config,
76-
openapi_config: Optional[OpenApiConfiguration] = None,
77-
**kwargs,
73+
config: Config, openapi_config: Optional[OpenApiConfiguration] = None, **kwargs
7874
) -> OpenApiConfiguration:
7975
if openapi_config:
8076
openapi_config = OpenApiConfigFactory.copy(
81-
openapi_config=openapi_config,
82-
api_key=config.api_key,
83-
host=config.host,
77+
openapi_config=openapi_config, api_key=config.api_key, host=config.host
8478
)
8579
elif openapi_config is None:
8680
openapi_config = OpenApiConfigFactory.build(api_key=config.api_key, host=config.host)

pinecone/config/openapi.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
from urllib3.connection import HTTPConnection
99

10-
from pinecone.core.openapi.shared.configuration import (
11-
Configuration as OpenApiConfiguration,
12-
)
10+
from pinecone.core.openapi.shared.configuration import Configuration as OpenApiConfiguration
1311

1412
TCP_KEEPINTVL = 60 # Sec
1513
TCP_KEEPIDLE = 300 # Sec
@@ -29,7 +27,9 @@ def build(cls, api_key: str, host: Optional[str] = None, **kwargs):
2927
return openapi_config
3028

3129
@classmethod
32-
def copy(cls, openapi_config: OpenApiConfiguration, api_key: str, host: str) -> OpenApiConfiguration:
30+
def copy(
31+
cls, openapi_config: OpenApiConfiguration, api_key: str, host: str
32+
) -> OpenApiConfiguration:
3333
"""
3434
Copy a user-supplied openapi configuration and update it with the user's api key and host.
3535
If they have not specified other socket configuration, we will use the default values.
@@ -88,13 +88,7 @@ def _get_socket_options(
8888
and hasattr(socket, "TCP_KEEPCNT")
8989
):
9090
socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, keep_alive_idle_sec)]
91-
socket_params += [
92-
(
93-
socket.IPPROTO_TCP,
94-
socket.TCP_KEEPINTVL,
95-
keep_alive_interval_sec,
96-
)
97-
]
91+
socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, keep_alive_interval_sec)]
9892
socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, keep_alive_tries)]
9993

10094
# TCP Keep Alive Probes for Windows OS

pinecone/config/pinecone_config.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ def build(
1717
additional_headers: Optional[Dict[str, str]] = {},
1818
**kwargs,
1919
) -> Config:
20-
host = host or kwargs.get("host") or os.getenv("PINECONE_CONTROLLER_HOST") or DEFAULT_CONTROLLER_HOST
20+
host = (
21+
host
22+
or kwargs.get("host")
23+
or os.getenv("PINECONE_CONTROLLER_HOST")
24+
or DEFAULT_CONTROLLER_HOST
25+
)
2126
headers_json = os.getenv("PINECONE_ADDITIONAL_HEADERS")
2227
if headers_json:
2328
try:
@@ -27,8 +32,5 @@ def build(
2732
logger.warn(f"Ignoring PINECONE_ADDITIONAL_HEADERS: {e}")
2833

2934
return ConfigBuilder.build(
30-
api_key=api_key,
31-
host=host,
32-
additional_headers=additional_headers,
33-
**kwargs,
35+
api_key=api_key, host=host, additional_headers=additional_headers, **kwargs
3436
)

pinecone/control/pinecone.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66

77
from pinecone.config import PineconeConfig, Config, ConfigBuilder
88

9-
from pinecone.core.openapi.control.api.manage_indexes_api import (
10-
ManageIndexesApi,
11-
)
9+
from pinecone.core.openapi.control.api.manage_indexes_api import ManageIndexesApi
1210
from pinecone.core.openapi.shared.api_client import ApiClient
1311

14-
from pinecone.utils import (
15-
normalize_host,
16-
setup_openapi_client,
17-
build_plugin_setup_client,
18-
)
12+
13+
from pinecone.utils import normalize_host, setup_openapi_client, build_plugin_setup_client
1914
from pinecone.core.openapi.control.models import (
2015
CreateCollectionRequest,
2116
CreateIndexRequest,
@@ -214,7 +209,7 @@ def __init__(
214209

215210
if kwargs.get("openapi_config", None):
216211
raise Exception(
217-
"Passing openapi_config is no longer supported. Please pass settings such as proxy_url, proxy_headers, ssl_ca_certs, and ssl_verify directly to the Pinecone constructor as keyword arguments. See the README at https://github.com/pinecone-io/pinecone-python-client for examples.",
212+
"Passing openapi_config is no longer supported. Please pass settings such as proxy_url, proxy_headers, ssl_ca_certs, and ssl_verify directly to the Pinecone constructor as keyword arguments. See the README at https://github.com/pinecone-io/pinecone-python-client for examples."
218213
)
219214

220215
self.openapi_config = ConfigBuilder.build_openapi_config(self.config, **kwargs)
@@ -353,10 +348,7 @@ def _parse_non_empty_args(args: List[Tuple[str, Any]]) -> Dict[str, Any]:
353348
raise ValueError("spec must contain either 'serverless' or 'pod' key")
354349
elif isinstance(spec, ServerlessSpec):
355350
index_spec = IndexSpec(
356-
serverless=ServerlessSpecModel(
357-
cloud=spec.cloud,
358-
region=spec.region,
359-
)
351+
serverless=ServerlessSpecModel(cloud=spec.cloud, region=spec.region)
360352
)
361353
elif isinstance(spec, PodSpec):
362354
args_dict = _parse_non_empty_args(
@@ -368,14 +360,12 @@ def _parse_non_empty_args(args: List[Tuple[str, Any]]) -> Dict[str, Any]:
368360
]
369361
)
370362
if spec.metadata_config:
371-
args_dict["metadata_config"] = PodSpecMetadataConfig(indexed=spec.metadata_config.get("indexed", None))
363+
args_dict["metadata_config"] = PodSpecMetadataConfig(
364+
indexed=spec.metadata_config.get("indexed", None)
365+
)
372366

373367
index_spec = IndexSpec(
374-
pod=PodSpecModel(
375-
environment=spec.environment,
376-
pod_type=spec.pod_type,
377-
**args_dict,
378-
)
368+
pod=PodSpecModel(environment=spec.environment, pod_type=spec.pod_type, **args_dict)
379369
)
380370
else:
381371
raise TypeError("spec must be of type dict, ServerlessSpec, or PodSpec")
@@ -387,7 +377,7 @@ def _parse_non_empty_args(args: List[Tuple[str, Any]]) -> Dict[str, Any]:
387377
metric=metric,
388378
spec=index_spec,
389379
deletion_protection=dp,
390-
),
380+
)
391381
)
392382

393383
def is_ready():
@@ -630,7 +620,9 @@ def create_collection(self, name: str, source: str):
630620
:param source: Name of the source index
631621
"""
632622
api_instance = self.index_api
633-
api_instance.create_collection(create_collection_request=CreateCollectionRequest(name=name, source=source))
623+
api_instance.create_collection(
624+
create_collection_request=CreateCollectionRequest(name=name, source=source)
625+
)
634626

635627
def list_collections(self) -> CollectionList:
636628
"""List all collections

pinecone/data/errors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@ def __init__(self, sparse_values_dict):
4040

4141
class MetadataDictionaryExpectedError(ValueError, TypeError):
4242
def __init__(self, item):
43-
message = f"Column `metadata` is expected to be a dictionary, found {type(item['metadata'])}"
43+
message = (
44+
f"Column `metadata` is expected to be a dictionary, found {type(item['metadata'])}"
45+
)
4446
super().__init__(message)

pinecone/data/features/bulk_import.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
class ImportFeatureMixin:
2828
def __init__(self, **kwargs):
29-
config = ConfigBuilder.build(
30-
**kwargs,
29+
config = ConfigBuilder.build(**kwargs)
30+
openapi_config = ConfigBuilder.build_openapi_config(
31+
config, kwargs.get("openapi_config", None)
3132
)
32-
openapi_config = ConfigBuilder.build_openapi_config(config, kwargs.get("openapi_config", None))
3333

3434
if kwargs.get("__import_operations_api", None):
3535
self.__import_operations_api = kwargs.get("__import_operations_api")
@@ -123,10 +123,7 @@ def list_imports(self, **kwargs) -> Iterator[List[ImportModel]]:
123123
done = True
124124

125125
def list_imports_paginated(
126-
self,
127-
limit: Optional[int] = None,
128-
pagination_token: Optional[str] = None,
129-
**kwargs,
126+
self, limit: Optional[int] = None, pagination_token: Optional[str] = None, **kwargs
130127
) -> ImportListResponse:
131128
"""
132129
The list_imports_paginated operation returns information about import operations.
@@ -158,12 +155,7 @@ def list_imports_paginated(
158155
Returns: ImportListResponse object which contains the list of operations as ImportModel objects, pagination information,
159156
and usage showing the number of read_units consumed.
160157
"""
161-
args_dict = parse_non_empty_args(
162-
[
163-
("limit", limit),
164-
("pagination_token", pagination_token),
165-
]
166-
)
158+
args_dict = parse_non_empty_args([("limit", limit), ("pagination_token", pagination_token)])
167159
return self.__import_operations_api.list_imports(**args_dict)
168160

169161
def describe_import(self, id: str) -> ImportModel:

0 commit comments

Comments
 (0)