Skip to content

Commit 79248a2

Browse files
Merge pull request #120 from philvarner/pv/query-extension-operator-names
Fix STAC API Query Extension operator names from ne->neq, le->lte, and ge->gte
2 parents 389706f + 49a7d6e commit 79248a2

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

Diff for: CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Add official support for python 3.12
77
- Enforce required `type` key for `Collection` and `Catalog` models
88
- Add queryables link relation type (#123, @constantinius)
9+
- Fix STAC API Query Extension operator names from ne->neq, le->lte, and ge->gte (#120, @philvarner)
910

1011
3.0.0 (2024-01-25)
1112
------------------

Diff for: pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ exclude = ["tests", ".venv"]
8787

8888
[tool.ruff]
8989
line-length = 88
90+
91+
[tool.ruff.lint]
9092
select = [
9193
"C",
9294
"E",

Diff for: stac_pydantic/api/extensions/query.py

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""Query Extension."""
2+
3+
import warnings
14
from enum import auto
25
from types import DynamicClassAttribute
36
from typing import Any, Callable
@@ -9,11 +12,14 @@
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

Comments
 (0)