You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
postgrest: range filters are typed as Tuple[int, int], so timestamp and numeric ranges fail type checking #1787
range_gt, range_gte, range_lt, range_lte, range_adjacent (and sl, sr, nxl, nxr, adj) annotate the bounds as Tuple[int, int]. Range filters are mostly used on tsrange, tstzrange, daterange and numrange columns. The Python reference and this repo's own tests (tests/_async/test_filter_request_builder.py::test_range_greater_than) pass a list of timestamp strings:
At runtime this works: the bounds are formatted with f"({range[0]},{range[1]})". But mypy and pyright reject it, and they also reject float bounds such as (1.5, 9.99).
$ python repro.py
select=%2A&during=sr.%282000-01-02+08%3A00%2C2000-01-02+09%3A00%29
$ mypy repro.py
repro.py:8: error: Argument 2 to "range_gt" of "BaseFilterRequestBuilder" has incompatible type "list[str]"; expected "tuple[int, int]" [arg-type]
repro.py:11: error: Argument 2 to "range_lt" of "BaseFilterRequestBuilder" has incompatible type "tuple[float, float]"; expected "tuple[int, int]" [arg-type]
Type the bounds as Sequence[FilterValue]. That is the FilterValue alias #1534 introduced for in_/cs/cd/ov. Runtime behaviour is unchanged. I have a patch with typed tests ready.
Activity