From ab1f9e82184b2c9eeb212537ed3c262a9f2fe636 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Mon, 16 Dec 2024 14:41:42 -0500 Subject: [PATCH] More more mypy fixes --- pinecone/data/types/query_filter.py | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 pinecone/data/types/query_filter.py diff --git a/pinecone/data/types/query_filter.py b/pinecone/data/types/query_filter.py new file mode 100644 index 00000000..927382f6 --- /dev/null +++ b/pinecone/data/types/query_filter.py @@ -0,0 +1,33 @@ +from typing import Literal, Dict, List, Union + +FieldValue = Union[str, int, float, bool] + +ExactMatchFilter = Dict[str, FieldValue] + +EqFilter = Dict[Literal["$eq"], FieldValue] +NeFilter = Dict[Literal["$ne"], FieldValue] + +NumericFieldValue = Union[int, float] +GtFilter = Dict[Literal["$gt"], NumericFieldValue] +GteFilter = Dict[Literal["$gte"], NumericFieldValue] +LtFilter = Dict[Literal["$lt"], NumericFieldValue] +LteFilter = Dict[Literal["$lte"], NumericFieldValue] + +InFilter = Dict[Literal["$in"], List[FieldValue]] +NinFilter = Dict[Literal["$nin"], List[FieldValue]] + + +SimpleFilter = Union[ + ExactMatchFilter, + EqFilter, + NeFilter, + GtFilter, + GteFilter, + LtFilter, + LteFilter, + InFilter, + NinFilter, +] +AndFilter = Dict[Literal["$and"], List[SimpleFilter]] + +FilterTypedDict = Union[SimpleFilter, AndFilter]