exa-py 1.1.6__tar.gz → 1.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of exa-py might be problematic. Click here for more details.
- {exa_py-1.1.6 → exa_py-1.1.7}/PKG-INFO +1 -1
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py/api.py +13 -23
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py.egg-info/PKG-INFO +1 -1
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py.egg-info/SOURCES.txt +2 -1
- {exa_py-1.1.6 → exa_py-1.1.7}/setup.py +1 -1
- exa_py-1.1.7/test/test.py +12 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/README.md +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py/__init__.py +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py/py.typed +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py/utils.py +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py.egg-info/dependency_links.txt +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py.egg-info/requires.txt +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/exa_py.egg-info/top_level.txt +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/pyproject.toml +0 -0
- {exa_py-1.1.6 → exa_py-1.1.7}/setup.cfg +0 -0
|
@@ -15,6 +15,8 @@ from typing import (
|
|
|
15
15
|
overload,
|
|
16
16
|
Union,
|
|
17
17
|
Literal,
|
|
18
|
+
get_origin,
|
|
19
|
+
get_args
|
|
18
20
|
)
|
|
19
21
|
from typing_extensions import TypedDict
|
|
20
22
|
|
|
@@ -144,8 +146,6 @@ CONTENTS_OPTIONS_TYPES = {
|
|
|
144
146
|
"filter_empty_results": [bool],
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
|
|
148
|
-
|
|
149
149
|
# FOR BETA OPTIONS
|
|
150
150
|
# if is_beta:
|
|
151
151
|
|
|
@@ -165,30 +165,20 @@ def validate_search_options(
|
|
|
165
165
|
for key, value in options.items():
|
|
166
166
|
if key not in expected:
|
|
167
167
|
raise ValueError(f"Invalid option: '{key}'")
|
|
168
|
-
if
|
|
168
|
+
if value is None:
|
|
169
|
+
continue
|
|
170
|
+
expected_types = expected[key]
|
|
171
|
+
if not any(is_valid_type(value, t) for t in expected_types):
|
|
169
172
|
raise ValueError(
|
|
170
|
-
f"Invalid
|
|
173
|
+
f"Invalid value for option '{key}': {value}. Expected one of {expected_types}"
|
|
171
174
|
)
|
|
172
175
|
|
|
173
|
-
def
|
|
174
|
-
if
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if get_origin(class_or_tuple) is not None:
|
|
181
|
-
# Handle subscripted generics
|
|
182
|
-
origin = get_origin(class_or_tuple)
|
|
183
|
-
args = get_args(class_or_tuple)
|
|
184
|
-
|
|
185
|
-
if origin is list:
|
|
186
|
-
return isinstance(obj, list) and all(isinstance(item, args[0]) for item in obj)
|
|
187
|
-
elif origin is dict:
|
|
188
|
-
return isinstance(obj, dict) and all(isinstance(k, args[0]) and isinstance(v, args[1]) for k, v in obj.items())
|
|
189
|
-
# Add more cases for other generic types as needed
|
|
190
|
-
|
|
191
|
-
return isinstance(obj, class_or_tuple)
|
|
176
|
+
def is_valid_type(value, expected_type):
|
|
177
|
+
if get_origin(expected_type) is Literal:
|
|
178
|
+
return value in get_args(expected_type)
|
|
179
|
+
if isinstance(expected_type, type):
|
|
180
|
+
return isinstance(value, expected_type)
|
|
181
|
+
return False # For any other case
|
|
192
182
|
|
|
193
183
|
class TextContentsOptions(TypedDict, total=False):
|
|
194
184
|
"""A class representing the options that you can specify when requesting text
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|