Skip to content

refactor(postgrest): replace Any with explicit types in array filters#1534

Open
gottostartsomewhere wants to merge 1 commit into
supabase:mainfrom
gottostartsomewhere:fix/postgrest-filter-types-followup
Open

refactor(postgrest): replace Any with explicit types in array filters#1534
gottostartsomewhere wants to merge 1 commit into
supabase:mainfrom
gottostartsomewhere:fix/postgrest-filter-types-followup

Conversation

@gottostartsomewhere

Copy link
Copy Markdown
Contributor

Follow-up to #1530.

In the review there, @o-santi noted the proper fix is to remove Any from the filter arguments and be stricter about the types users provide. This does that for the array/collection filters.

Change

  • Add a FilterValue = Union[str, int, float, bool] alias in types.py.
  • Type in_, cs, cd, contains, contained_by, ov, and overlaps with Iterable[FilterValue] instead of Iterable[Any], and type the JSON-object branch of contains/contained_by/ov as Dict[str, JSON].
  • Runtime str coercion (from fix(postgrest): coerce non-string values in array filters #1530) is kept, so integer arrays still work — this just makes the accepted types explicit at the type level.

Checks

  • mypy clean on the changed files.
  • Existing sync + async filter tests pass (84).

Scope

I kept this to the array/collection filters that #1530 touched. Happy to extend the same treatment to the scalar operators (eq, neq, gt, …, which still take value: Any) in this PR or a separate one — whichever you prefer. And of course feel free to adjust the target types or close this if you'd rather own the wider cleanup.

Address review on supabase#1530: instead of only coercing values at runtime,
remove Any from the filter argument annotations. Add a FilterValue alias
(str | int | float | bool) and type the array/collection filters (in_, cs,
cd, contains, contained_by, ov, overlaps) with it, and type the JSON-object
branch as Dict[str, JSON]. Runtime str-coercion is kept so integer arrays
still work. mypy clean; existing tests pass.
@gottostartsomewhere
gottostartsomewhere requested review from a team and o-santi as code owners July 9, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant