diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2ae27d3..8c5c6cb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ - Add official support for python 3.12 - Enforce required `type` key for `Collection` and `Catalog` models - Add queryables link relation type (#123, @constantinius) +- Fix STAC API Query Extension operator names from ne->neq, le->lte, and ge->gte (#120, @philvarner) 3.0.0 (2024-01-25) ------------------ diff --git a/pyproject.toml b/pyproject.toml index a05ddcf..b975144 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,6 +87,8 @@ exclude = ["tests", ".venv"] [tool.ruff] line-length = 88 + +[tool.ruff.lint] select = [ "C", "E", diff --git a/stac_pydantic/api/extensions/query.py b/stac_pydantic/api/extensions/query.py index bc88960..fd526f1 100644 --- a/stac_pydantic/api/extensions/query.py +++ b/stac_pydantic/api/extensions/query.py @@ -1,3 +1,6 @@ +"""Query Extension.""" + +import warnings from enum import auto from types import DynamicClassAttribute from typing import Any, Callable @@ -9,11 +12,14 @@ _OPERATIONS = { "eq": lambda x, y: x == y, - "ne": lambda x, y: x != y, + "ne": lambda x, y: x != y, # deprecated + "neq": lambda x, y: x != y, "lt": lambda x, y: x < y, - "le": lambda x, y: x <= y, + "le": lambda x, y: x <= y, # deprecated + "lte": lambda x, y: x <= y, "gt": lambda x, y: x > y, - "ge": lambda x, y: x >= y, + "ge": lambda x, y: x >= y, # deprecated + "gte": lambda x, y: x >= y, "startsWith": lambda x, y: x.startsWith(y), "endsWith": lambda x, y: x.endsWith(y), "contains": lambda x, y: y in x, @@ -26,11 +32,14 @@ class Operator(str, AutoValueEnum): """ eq = auto() - ne = auto() + ne = auto() # deprecated + neq = auto() lt = auto() - le = auto() + le = auto() # deprecated + lte = auto() gt = auto() - ge = auto() + ge = auto() # deprecated + gte = auto() startsWith = auto() endsWith = auto() contains = auto() @@ -38,4 +47,12 @@ class Operator(str, AutoValueEnum): @DynamicClassAttribute def operator(self) -> Callable[[Any, Any], bool]: """Return python operator""" + if self._value_ in ["ne", "ge", "le"]: + newvalue = self._value_.replace("e", "te") + warnings.warn( + f"`{self._value_}` is deprecated, please use `{newvalue}`", + DeprecationWarning, + stacklevel=3, + ) + return _OPERATIONS[self._value_]