diff --git a/pyproject.toml b/pyproject.toml index 1f26b2c..56fb095 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", ] -dependencies = ["requests"] +dependencies = ["requests", "typing-extensions"] dynamic = ["version"] [project.urls] diff --git a/src/typesense/analytics_rule_v1.py b/src/typesense/analytics_rule_v1.py index dc6890d..87a156d 100644 --- a/src/typesense/analytics_rule_v1.py +++ b/src/typesense/analytics_rule_v1.py @@ -27,7 +27,10 @@ else: import typing_extensions as typing +from typing_extensions import deprecated + from typesense.api_call import ApiCall +from typesense.logger import warn_deprecation from typesense.types.analytics_rule_v1 import ( RuleDeleteSchema, RuleSchemaForCounters, @@ -35,6 +38,9 @@ ) +@deprecated( + "AnalyticsRuleV1 is deprecated on v30+. Use client.analytics.rules[rule_id] instead." +) class AnalyticsRuleV1: """ Class for managing individual analytics rules in Typesense (V1). @@ -47,6 +53,10 @@ class AnalyticsRuleV1: rule_id (str): The ID of the analytics rule. """ + @warn_deprecation( # type: ignore[misc] + "AnalyticsRuleV1 is deprecated on v30+. Use client.analytics.rules[rule_id] instead.", + flag_name="analytics_rules_v1_deprecation", + ) def __init__(self, api_call: ApiCall, rule_id: str): """ Initialize the AnalyticsRuleV1 object. @@ -102,5 +112,3 @@ def _endpoint_path(self) -> str: from typesense.analytics_rules_v1 import AnalyticsRulesV1 return "/".join([AnalyticsRulesV1.resource_path, self.rule_id]) - - diff --git a/src/typesense/analytics_rules_v1.py b/src/typesense/analytics_rules_v1.py index a850d37..2c93a98 100644 --- a/src/typesense/analytics_rules_v1.py +++ b/src/typesense/analytics_rules_v1.py @@ -27,6 +27,8 @@ import sys +from typesense.logger import warn_deprecation + if sys.version_info >= (3, 11): import typing else: @@ -63,6 +65,10 @@ class AnalyticsRulesV1(object): resource_path: typing.Final[str] = "/analytics/rules" + @warn_deprecation( # type: ignore[misc] + "AnalyticsRulesV1 is deprecated on v30+. Use client.analytics instead.", + flag_name="analytics_rules_v1_deprecation", + ) def __init__(self, api_call: ApiCall): """ Initialize the AnalyticsRulesV1 object. @@ -161,5 +167,3 @@ def retrieve(self) -> RulesRetrieveSchema: entity_type=RulesRetrieveSchema, ) return response - - diff --git a/src/typesense/analytics_v1.py b/src/typesense/analytics_v1.py index cbacc4b..657af6c 100644 --- a/src/typesense/analytics_v1.py +++ b/src/typesense/analytics_v1.py @@ -17,13 +17,13 @@ versions through the use of the typing_extensions library. """ +from typing_extensions import deprecated + from typesense.analytics_rules_v1 import AnalyticsRulesV1 from typesense.api_call import ApiCall -from typesense.logger import logger - -_analytics_v1_deprecation_warned = False +@deprecated("AnalyticsV1 is deprecated on v30+. Use client.analytics instead.") class AnalyticsV1(object): """ Class for managing analytics in Typesense (V1). @@ -46,13 +46,6 @@ def __init__(self, api_call: ApiCall) -> None: @property def rules(self) -> AnalyticsRulesV1: - global _analytics_v1_deprecation_warned - if not _analytics_v1_deprecation_warned: - logger.warning( - "AnalyticsV1 is deprecated and will be removed in a future release. " - "Use client.analytics instead." - ) - _analytics_v1_deprecation_warned = True return self._rules diff --git a/src/typesense/client.py b/src/typesense/client.py index 92354b2..19cae3a 100644 --- a/src/typesense/client.py +++ b/src/typesense/client.py @@ -28,6 +28,8 @@ import sys +from typing_extensions import deprecated + from typesense.types.document import DocumentSchema if sys.version_info >= (3, 11): @@ -36,13 +38,14 @@ import typing_extensions as typing from typesense.aliases import Aliases -from typesense.analytics_v1 import AnalyticsV1 from typesense.analytics import Analytics +from typesense.analytics_v1 import AnalyticsV1 from typesense.api_call import ApiCall from typesense.collection import Collection from typesense.collections import Collections from typesense.configuration import ConfigDict, Configuration from typesense.conversations_models import ConversationsModels +from typesense.curation_sets import CurationSets from typesense.debug import Debug from typesense.keys import Keys from typesense.metrics import Metrics @@ -73,7 +76,8 @@ class Client: keys (Keys): Instance for managing API keys. aliases (Aliases): Instance for managing collection aliases. analyticsV1 (AnalyticsV1): Instance for analytics operations (V1). - analytics (AnalyticsV30): Instance for analytics operations (v30). + analytics (Analytics): Instance for analytics operations (v30). + curation_sets (CurationSets): Instance for Curation Sets (v30+) stemming (Stemming): Instance for stemming dictionary operations. operations (Operations): Instance for various Typesense operations. debug (Debug): Instance for debug operations. @@ -93,8 +97,10 @@ def __init__(self, config_dict: ConfigDict) -> None: Example: >>> config = { ... "api_key": "your_api_key", - ... "nodes": [{"host": "localhost", "port": "8108", "protocol": "http"}], - ... "connection_timeout_seconds": 2 + ... "nodes": [ + ... {"host": "localhost", "port": "8108", "protocol": "http"} + ... ], + ... "connection_timeout_seconds": 2, ... } >>> client = Client(config) """ @@ -104,9 +110,10 @@ def __init__(self, config_dict: ConfigDict) -> None: self.multi_search = MultiSearch(self.api_call) self.keys = Keys(self.api_call) self.aliases = Aliases(self.api_call) - self.analyticsV1 = AnalyticsV1(self.api_call) + self._analyticsV1 = AnalyticsV1(self.api_call) self.analytics = Analytics(self.api_call) self.stemming = Stemming(self.api_call) + self.curation_sets = CurationSets(self.api_call) self.operations = Operations(self.api_call) self.debug = Debug(self.api_call) self.stopwords = Stopwords(self.api_call) @@ -115,6 +122,14 @@ def __init__(self, config_dict: ConfigDict) -> None: self.conversations_models = ConversationsModels(self.api_call) self.nl_search_models = NLSearchModels(self.api_call) + @property + @deprecated( + "AnalyticsV1 is deprecated on v30+. Use client.analytics instead.", + category=None, + ) + def analyticsV1(self) -> AnalyticsV1: + return self._analyticsV1 + def typed_collection( self, *, @@ -140,7 +155,6 @@ def typed_collection( >>> class Company(DocumentSchema): ... name: str ... num_employees: int - ... >>> client = Client(config) >>> companies_collection = client.typed_collection(model=Company) # This is equivalent to: diff --git a/src/typesense/collection.py b/src/typesense/collection.py index f648ebf..a898656 100644 --- a/src/typesense/collection.py +++ b/src/typesense/collection.py @@ -20,6 +20,8 @@ import sys +from typing_extensions import deprecated + from typesense.types.collection import CollectionSchema, CollectionUpdateSchema if sys.version_info >= (3, 11): @@ -63,8 +65,24 @@ def __init__(self, api_call: ApiCall, name: str): self.name = name self.api_call = api_call self.documents: Documents[TDoc] = Documents(api_call, name) - self.overrides = Overrides(api_call, name) - self.synonyms = Synonyms(api_call, name) + self._overrides = Overrides(api_call, name) + self._synonyms = Synonyms(api_call, name) + + @property + @deprecated( + "Synonyms is deprecated on v30+. Use client.synonym_sets instead.", + category=None, + ) + def synonyms(self) -> Synonyms: + return self._synonyms + + @property + @deprecated( + "Overrides is deprecated on v30+. Use client.curation_sets instead.", + category=None, + ) + def overrides(self) -> Overrides: + return self._overrides def retrieve(self) -> CollectionSchema: """ diff --git a/src/typesense/configuration.py b/src/typesense/configuration.py index d59ac5e..d82408d 100644 --- a/src/typesense/configuration.py +++ b/src/typesense/configuration.py @@ -80,6 +80,8 @@ class ConfigDict(typing.TypedDict): dictionaries or URLs that represent the read replica nodes. connection_timeout_seconds (float): The connection timeout in seconds. + + suppress_deprecation_warnings (bool): Whether to suppress deprecation warnings. """ nodes: typing.List[typing.Union[str, NodeConfigDict]] @@ -96,6 +98,7 @@ class ConfigDict(typing.TypedDict): typing.List[typing.Union[str, NodeConfigDict]] ] # deprecated connection_timeout_seconds: typing.NotRequired[float] + suppress_deprecation_warnings: typing.NotRequired[bool] class Node: @@ -220,6 +223,7 @@ def __init__( ) self.verify = config_dict.get("verify", True) self.additional_headers = config_dict.get("additional_headers", {}) + self.suppress_deprecation_warnings = config_dict.get("suppress_deprecation_warnings", False) def _handle_nearest_node( self, @@ -371,7 +375,7 @@ def show_deprecation_warnings(config_dict: ConfigDict) -> None: to check for deprecated fields. """ if config_dict.get("timeout_seconds"): - logger.warn( + logger.warning( " ".join( [ "Deprecation warning: timeout_seconds is now renamed", @@ -381,7 +385,7 @@ def show_deprecation_warnings(config_dict: ConfigDict) -> None: ) if config_dict.get("master_node"): - logger.warn( + logger.warning( " ".join( [ "Deprecation warning: master_node is now consolidated", @@ -391,7 +395,7 @@ def show_deprecation_warnings(config_dict: ConfigDict) -> None: ) if config_dict.get("read_replica_nodes"): - logger.warn( + logger.warning( " ".join( [ "Deprecation warning: read_replica_nodes is now", diff --git a/src/typesense/curation_set.py b/src/typesense/curation_set.py index 3828161..7cf53f5 100644 --- a/src/typesense/curation_set.py +++ b/src/typesense/curation_set.py @@ -9,11 +9,12 @@ from typesense.api_call import ApiCall from typesense.types.curation_set import ( - CurationSetSchema, + CurationItemDeleteSchema, + CurationItemSchema, CurationSetDeleteSchema, CurationSetListItemResponseSchema, - CurationItemSchema, - CurationItemDeleteSchema, + CurationSetSchema, + CurationSetUpsertSchema, ) @@ -43,6 +44,17 @@ def delete(self) -> CurationSetDeleteSchema: ) return response + def upsert( + self, + payload: CurationSetUpsertSchema, + ) -> CurationSetSchema: + response: CurationSetSchema = self.api_call.put( + "/".join([self._endpoint_path]), + body=payload, + entity_type=CurationSetSchema, + ) + return response + # Items sub-resource @property def _items_path(self) -> str: @@ -92,5 +104,3 @@ def delete_item(self, item_id: str) -> CurationItemDeleteSchema: entity_type=CurationItemDeleteSchema, ) return response - - diff --git a/src/typesense/curation_sets.py b/src/typesense/curation_sets.py index b13303e..4a30abc 100644 --- a/src/typesense/curation_sets.py +++ b/src/typesense/curation_sets.py @@ -10,9 +10,7 @@ from typesense.api_call import ApiCall from typesense.curation_set import CurationSet from typesense.types.curation_set import ( - CurationSetSchema, CurationSetsListResponseSchema, - CurationSetUpsertSchema, ) @@ -34,15 +32,3 @@ def __getitem__(self, curation_set_name: str) -> CurationSet: from typesense.curation_set import CurationSet as PerSet return PerSet(self.api_call, curation_set_name) - - def upsert( - self, - curation_set_name: str, - payload: CurationSetUpsertSchema, - ) -> CurationSetSchema: - response: CurationSetSchema = self.api_call.put( - "/".join([CurationSets.resource_path, curation_set_name]), - body=payload, - entity_type=CurationSetSchema, - ) - return response diff --git a/src/typesense/logger.py b/src/typesense/logger.py index 1be7890..2834e28 100644 --- a/src/typesense/logger.py +++ b/src/typesense/logger.py @@ -1,6 +1,78 @@ """Logging configuration for the Typesense Python client.""" +import functools import logging +import sys + +if sys.version_info >= (3, 11): + import typing +else: + import typing_extensions as typing logger = logging.getLogger("typesense") logger.setLevel(logging.WARN) + +_deprecation_warnings: typing.Dict[str, bool] = {} + +if sys.version_info >= (3, 11): + from typing import ParamSpec, TypeVar +else: + from typing_extensions import ParamSpec, TypeVar + +P = ParamSpec("P") +R = TypeVar("R") + + +def warn_deprecation( + message: str, + *, + flag_name: typing.Union[str, None] = None, +) -> typing.Callable[[typing.Callable[P, R]], typing.Callable[P, R]]: + """ + Decorator to warn about deprecation when a method is called. + + This decorator will log a deprecation warning once per flag_name when the + decorated method is called. The warning is only shown once to avoid spam. + + Args: + message: The deprecation warning message to display. + flag_name: Optional name for the warning flag. If not provided, a default + name will be generated based on the function's module and name. + + Returns: + A decorator function that wraps the target method. + + Example: + >>> @warn_deprecation("This method is deprecated", flag_name="my_method") + ... def my_method(self): + ... return "result" + """ + + def decorator(func: typing.Callable[P, R]) -> typing.Callable[P, R]: + if flag_name is None: + flag = f"{func.__module__}.{func.__qualname__}" + else: + flag = flag_name + + @functools.wraps(func) + def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: + suppress_warnings = False + if ( + args + and len(args) > 1 + and args[1] + and args[1].__class__.__name__ == "ApiCall" + and hasattr(args[1], "config") + ): + suppress_warnings = getattr( + args[1].config, "suppress_deprecation_warnings", False + ) + + if not suppress_warnings and not _deprecation_warnings.get(flag, False): + logger.warning(f"Deprecation warning: {message}") + _deprecation_warnings[flag] = True + return func(*args, **kwargs) + + return typing.cast(typing.Callable[P, R], wrapper) + + return decorator diff --git a/src/typesense/override.py b/src/typesense/override.py index 478a6d8..a9613b0 100644 --- a/src/typesense/override.py +++ b/src/typesense/override.py @@ -21,10 +21,14 @@ versions through the use of the typing_extensions library. """ +from typing_extensions import deprecated + from typesense.api_call import ApiCall +from typesense.logger import warn_deprecation from typesense.types.override import OverrideDeleteSchema, OverrideSchema +@deprecated("Override is deprecated on v30+. Use client.curation_sets instead.") class Override: """ Class for managing individual overrides in a Typesense collection. @@ -38,6 +42,11 @@ class Override: override_id (str): The ID of the override. """ + @warn_deprecation( # type: ignore[misc] + "The override API (collections/{collection}/overrides/{override_id}) is deprecated is removed on v30+. " + "Use curation sets (curation_sets) instead.", + flag_name="overrides_deprecation", + ) def __init__( self, api_call: ApiCall, diff --git a/src/typesense/overrides.py b/src/typesense/overrides.py index 2674f42..4f8bc80 100644 --- a/src/typesense/overrides.py +++ b/src/typesense/overrides.py @@ -29,7 +29,10 @@ import sys +from typing_extensions import deprecated + from typesense.api_call import ApiCall +from typesense.logger import warn_deprecation from typesense.override import Override from typesense.types.override import ( OverrideCreateSchema, @@ -43,6 +46,7 @@ import typing_extensions as typing +@deprecated("Overrides is deprecated on v30+. Use client.curation_sets instead.") class Overrides: """ Class for managing overrides in a Typesense collection. @@ -59,11 +63,15 @@ class Overrides: resource_path: typing.Final[str] = "overrides" + @warn_deprecation( # type: ignore[misc] + "Overrides is deprecated on v30+. Use client.curation_sets instead.", + flag_name="overrides_deprecation", + ) def __init__( self, api_call: ApiCall, collection_name: str, - ) -> None: + ) -> None: """ Initialize the Overrides object. diff --git a/src/typesense/synonym.py b/src/typesense/synonym.py index 53f9bd3..6bea97d 100644 --- a/src/typesense/synonym.py +++ b/src/typesense/synonym.py @@ -22,11 +22,9 @@ """ from typesense.api_call import ApiCall -from typesense.logger import logger +from typesense.logger import warn_deprecation from typesense.types.synonym import SynonymDeleteSchema, SynonymSchema -_synonym_deprecation_warned = False - class Synonym: """ @@ -41,6 +39,11 @@ class Synonym: synonym_id (str): The ID of the synonym. """ + @warn_deprecation( # type: ignore[misc] + "The synonym API (collections/{collection}/synonyms/{synonym_id}) is deprecated is removed on v30+. " + "Use synonym sets (synonym_sets) instead.", + flag_name="synonyms_deprecation", + ) def __init__( self, api_call: ApiCall, @@ -66,7 +69,6 @@ def retrieve(self) -> SynonymSchema: Returns: SynonymSchema: The schema containing the synonym details. """ - self._maybe_warn_deprecation() return self.api_call.get(self._endpoint_path(), entity_type=SynonymSchema) def delete(self) -> SynonymDeleteSchema: @@ -76,7 +78,6 @@ def delete(self) -> SynonymDeleteSchema: Returns: SynonymDeleteSchema: The schema containing the deletion response. """ - self._maybe_warn_deprecation() return self.api_call.delete( self._endpoint_path(), entity_type=SynonymDeleteSchema, @@ -100,12 +101,3 @@ def _endpoint_path(self) -> str: self.synonym_id, ], ) - - def _maybe_warn_deprecation(self) -> None: - global _synonym_deprecation_warned - if not _synonym_deprecation_warned: - logger.warning( - "The synonyms API (collections/{collection}/synonyms) is deprecated and will be " - "removed in a future release. Use synonym sets (synonym_sets) instead." - ) - _synonym_deprecation_warned = True diff --git a/src/typesense/synonym_set.py b/src/typesense/synonym_set.py index 0828791..e9eaae3 100644 --- a/src/typesense/synonym_set.py +++ b/src/typesense/synonym_set.py @@ -9,10 +9,11 @@ from typesense.api_call import ApiCall from typesense.types.synonym_set import ( + SynonymItemDeleteSchema, + SynonymItemSchema, + SynonymSetCreateSchema, SynonymSetDeleteSchema, SynonymSetRetrieveSchema, - SynonymItemSchema, - SynonymItemDeleteSchema, ) @@ -35,13 +36,21 @@ def retrieve(self) -> SynonymSetRetrieveSchema: ) return response + def upsert(self, set: SynonymSetCreateSchema) -> SynonymSetCreateSchema: + response: SynonymSetCreateSchema = self.api_call.put( + self._endpoint_path, + entity_type=SynonymSetCreateSchema, + body=set, + ) + return response + def delete(self) -> SynonymSetDeleteSchema: response: SynonymSetDeleteSchema = self.api_call.delete( self._endpoint_path, entity_type=SynonymSetDeleteSchema, ) return response - + @property def _items_path(self) -> str: return "/".join([self._endpoint_path, "items"]) # /synonym_sets/{name}/items @@ -57,9 +66,7 @@ def list_items( "offset": offset, } clean_params: typing.Dict[str, int] = { - k: v - for k, v in params.items() - if v is not None + k: v for k, v in params.items() if v is not None } response: typing.List[SynonymItemSchema] = self.api_call.get( self._items_path, @@ -91,5 +98,3 @@ def delete_item(self, item_id: str) -> SynonymItemDeleteSchema: "/".join([self._items_path, item_id]), entity_type=SynonymItemDeleteSchema ) return response - - diff --git a/src/typesense/synonym_sets.py b/src/typesense/synonym_sets.py index 543e77c..ee4587f 100644 --- a/src/typesense/synonym_sets.py +++ b/src/typesense/synonym_sets.py @@ -10,7 +10,6 @@ from typesense.api_call import ApiCall from typesense.synonym_set import SynonymSet from typesense.types.synonym_set import ( - SynonymSetCreateSchema, SynonymSetSchema, ) @@ -33,15 +32,3 @@ def __getitem__(self, synonym_set_name: str) -> SynonymSet: from typesense.synonym_set import SynonymSet as PerSet return PerSet(self.api_call, synonym_set_name) - - def upsert( - self, - synonym_set_name: str, - payload: SynonymSetCreateSchema, - ) -> SynonymSetSchema: - response: SynonymSetSchema = self.api_call.put( - "/".join([SynonymSets.resource_path, synonym_set_name]), - body=payload, - entity_type=SynonymSetSchema, - ) - return response diff --git a/src/typesense/synonyms.py b/src/typesense/synonyms.py index c1bd6b7..3a5622f 100644 --- a/src/typesense/synonyms.py +++ b/src/typesense/synonyms.py @@ -27,16 +27,16 @@ import sys +from typing_extensions import deprecated + from typesense.api_call import ApiCall +from typesense.logger import warn_deprecation from typesense.synonym import Synonym from typesense.types.synonym import ( SynonymCreateSchema, SynonymSchema, SynonymsRetrieveSchema, ) -from typesense.logger import logger - -_synonyms_deprecation_warned = False if sys.version_info >= (3, 11): import typing @@ -44,6 +44,7 @@ import typing_extensions as typing +@deprecated("Synonyms is deprecated on v30+. Use client.synonym_sets instead.") class Synonyms: """ Class for managing synonyms in a Typesense collection. @@ -60,7 +61,12 @@ class Synonyms: resource_path: typing.Final[str] = "synonyms" - def __init__(self, api_call: ApiCall, collection_name: str): + @warn_deprecation( # type: ignore[misc] + "The synonyms API (collections/{collection}/synonyms) is deprecated is removed on v30+. " + "Use synonym sets (synonym_sets) instead.", + flag_name="synonyms_deprecation", + ) + def __init__(self, api_call: ApiCall, collection_name: str) -> None: """ Initialize the Synonyms object. @@ -101,7 +107,6 @@ def upsert(self, synonym_id: str, schema: SynonymCreateSchema) -> SynonymSchema: Returns: SynonymSchema: The created or updated synonym. """ - self._maybe_warn_deprecation() response = self.api_call.put( self._endpoint_path(synonym_id), body=schema, @@ -116,7 +121,6 @@ def retrieve(self) -> SynonymsRetrieveSchema: Returns: SynonymsRetrieveSchema: The schema containing all synonyms. """ - self._maybe_warn_deprecation() response = self.api_call.get( self._endpoint_path(), entity_type=SynonymsRetrieveSchema, @@ -144,12 +148,3 @@ def _endpoint_path(self, synonym_id: typing.Union[str, None] = None) -> str: synonym_id, ], ) - - def _maybe_warn_deprecation(self) -> None: - global _synonyms_deprecation_warned - if not _synonyms_deprecation_warned: - logger.warning( - "The synonyms API (collections/{collection}/synonyms) is deprecated and will be " - "removed in a future release. Use synonym sets (synonym_sets) instead." - ) - _synonyms_deprecation_warned = True diff --git a/src/typesense/types/collection.py b/src/typesense/types/collection.py index 1ce839c..702fb41 100644 --- a/src/typesense/types/collection.py +++ b/src/typesense/types/collection.py @@ -225,10 +225,15 @@ class CollectionUpdateSchema(typing.TypedDict): """ - fields: typing.List[ - typing.Union[ - RegularCollectionFieldSchema, - ReferenceCollectionFieldSchema, - DropCollectionFieldSchema, + fields: typing.NotRequired[ + typing.List[ + typing.Union[ + RegularCollectionFieldSchema, + ReferenceCollectionFieldSchema, + DropCollectionFieldSchema, + ] ] ] + synonym_sets: typing.NotRequired[typing.List[str]] + curation_sets: typing.NotRequired[typing.List[str]] + diff --git a/tests/curation_sets_test.py b/tests/curation_sets_test.py index 82091d5..88c70bf 100644 --- a/tests/curation_sets_test.py +++ b/tests/curation_sets_test.py @@ -96,7 +96,7 @@ def test_upsert(fake_curation_sets: CurationSets) -> None: } ] } - response = fake_curation_sets.upsert("products", payload) + response = fake_curation_sets["products"].upsert(payload) assert response == json_response assert mock.call_count == 1 @@ -111,8 +111,7 @@ def test_actual_upsert( delete_all_curation_sets: None, ) -> None: """Test that the CurationSets object can upsert a curation set on Typesense Server.""" - response = actual_curation_sets.upsert( - "products", + response = actual_curation_sets["products"].upsert( { "items": [ { diff --git a/tests/synonym_sets_test.py b/tests/synonym_sets_test.py index fd0e532..f63c196 100644 --- a/tests/synonym_sets_test.py +++ b/tests/synonym_sets_test.py @@ -19,7 +19,6 @@ SynonymSetSchema, ) - pytestmark = pytest.mark.skipif( not is_v30_or_above( Client( @@ -102,7 +101,7 @@ def test_create(fake_synonym_sets: SynonymSets) -> None: } ] } - fake_synonym_sets.upsert("test-set", payload) + fake_synonym_sets["test-set"].upsert(payload) assert mock.call_count == 1 assert mock.called is True @@ -116,8 +115,7 @@ def test_actual_create( delete_all_synonym_sets: None, ) -> None: """Test that the SynonymSets object can create a synonym set on Typesense Server.""" - response = actual_synonym_sets.upsert( - "test-set", + response = actual_synonym_sets["test-set"].upsert( { "items": [ { diff --git a/uv.lock b/uv.lock index 0846166..376f24b 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.9" resolution-markers = [ "python_full_version >= '3.10'", @@ -440,6 +440,7 @@ name = "typesense" source = { virtual = "." } dependencies = [ { name = "requests" }, + { name = "typing-extensions" }, ] [package.dev-dependencies] @@ -457,7 +458,10 @@ dev = [ ] [package.metadata] -requires-dist = [{ name = "requests" }] +requires-dist = [ + { name = "requests" }, + { name = "typing-extensions" }, +] [package.metadata.requires-dev] dev = [