1+ """Query Extension."""
2+
3+ import warnings
14from enum import auto
25from types import DynamicClassAttribute
36from typing import Any , Callable
912
1013_OPERATIONS = {
1114 "eq" : lambda x , y : x == y ,
12- "ne" : lambda x , y : x != y ,
15+ "ne" : lambda x , y : x != y , # deprecated
16+ "neq" : lambda x , y : x != y ,
1317 "lt" : lambda x , y : x < y ,
14- "le" : lambda x , y : x <= y ,
18+ "le" : lambda x , y : x <= y , # deprecated
19+ "lte" : lambda x , y : x <= y ,
1520 "gt" : lambda x , y : x > y ,
16- "ge" : lambda x , y : x >= y ,
21+ "ge" : lambda x , y : x >= y , # deprecated
22+ "gte" : lambda x , y : x >= y ,
1723 "startsWith" : lambda x , y : x .startsWith (y ),
1824 "endsWith" : lambda x , y : x .endsWith (y ),
1925 "contains" : lambda x , y : y in x ,
@@ -26,16 +32,27 @@ class Operator(str, AutoValueEnum):
2632 """
2733
2834 eq = auto ()
29- ne = auto ()
35+ ne = auto () # deprecated
36+ neq = auto ()
3037 lt = auto ()
31- le = auto ()
38+ le = auto () # deprecated
39+ lte = auto ()
3240 gt = auto ()
33- ge = auto ()
41+ ge = auto () # deprecated
42+ gte = auto ()
3443 startsWith = auto ()
3544 endsWith = auto ()
3645 contains = auto ()
3746
3847 @DynamicClassAttribute
3948 def operator (self ) -> Callable [[Any , Any ], bool ]:
4049 """Return python operator"""
50+ if self ._value_ in ["ne" , "ge" , "le" ]:
51+ newvalue = self ._value_ .replace ("e" , "te" )
52+ warnings .warn (
53+ f"`{ self ._value_ } ` is deprecated, please use `{ newvalue } `" ,
54+ DeprecationWarning ,
55+ stacklevel = 3 ,
56+ )
57+
4158 return _OPERATIONS [self ._value_ ]
0 commit comments