1
+ """Query Extension."""
2
+
3
+ import warnings
1
4
from enum import auto
2
5
from types import DynamicClassAttribute
3
6
from typing import Any , Callable
9
12
10
13
_OPERATIONS = {
11
14
"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 ,
13
17
"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 ,
15
20
"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 ,
17
23
"startsWith" : lambda x , y : x .startsWith (y ),
18
24
"endsWith" : lambda x , y : x .endsWith (y ),
19
25
"contains" : lambda x , y : y in x ,
@@ -26,16 +32,27 @@ class Operator(str, AutoValueEnum):
26
32
"""
27
33
28
34
eq = auto ()
29
- ne = auto ()
35
+ ne = auto () # deprecated
36
+ neq = auto ()
30
37
lt = auto ()
31
- le = auto ()
38
+ le = auto () # deprecated
39
+ lte = auto ()
32
40
gt = auto ()
33
- ge = auto ()
41
+ ge = auto () # deprecated
42
+ gte = auto ()
34
43
startsWith = auto ()
35
44
endsWith = auto ()
36
45
contains = auto ()
37
46
38
47
@DynamicClassAttribute
39
48
def operator (self ) -> Callable [[Any , Any ], bool ]:
40
49
"""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
+
41
58
return _OPERATIONS [self ._value_ ]
0 commit comments