Skip to content

Commit 1d7a6e7

Browse files
committed
Allow int-valued list filters in _get_args (water_year, year, month, day, peak_since)
`get_peaks` (merged in fca3d6c) introduced five `int | list[int] | None` filters. The prior commit removed `_get_args`'s "list-of-non-str pass-through" clause to catch user errors like `parameter_code=[60, 65]` client-side — but the same clause was the only thing letting `water_year=[2020]` through. CI surfaced this via `test_get_peaks_water_year_filter`. Add the five known int-list filter names to `_NO_NORMALIZE_PARAMS` so they bypass string-iterable normalization. Existing string-list params still validate, and `parameter_code=[60, 65]` still raises TypeError client-side as intended. If future int-list params are added, they must be opted in here — this is intentional: the cost of one line per new param is a fair price for not silently passing user errors to the API.
1 parent 8dc70b2 commit 1d7a6e7

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

dataretrieval/waterdata/utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,15 +1185,21 @@ def _check_profiles(
11851185

11861186

11871187
# Param names that ``_get_args`` must NOT push through ``_normalize_str_iterable``.
1188-
# Scalar non-string knobs and ``list[float]`` params are detected by runtime
1189-
# type; only string-iterable-shaped params with special handling need to be
1190-
# named here: ``monitoring_location_id`` (validated separately), date-range
1191-
# params (which may contain ``pd.NaT``/None or interval strings), and bbox
1192-
# inputs (``list[float]``, sometimes a ``numpy.ndarray``).
1188+
# Scalar non-string knobs are detected by runtime type; only iterable-shaped
1189+
# params with special handling need to be named here:
1190+
# - ``monitoring_location_id`` is validated separately (AGENCY-ID format)
1191+
# - date-range params may contain ``pd.NaT``/None or interval strings
1192+
# - ``bbox``/``boundingBox`` are ``list[float]``, sometimes ``numpy.ndarray``
1193+
# - ``get_peaks``'s int-valued filters (``water_year`` etc.) are ``list[int]``
11931194
_NO_NORMALIZE_PARAMS = _DATE_RANGE_PARAMS | {
11941195
"monitoring_location_id",
11951196
"bbox",
11961197
"boundingBox",
1198+
"water_year",
1199+
"year",
1200+
"month",
1201+
"day",
1202+
"peak_since",
11971203
}
11981204

11991205
# Param names that must be a list of strings (never a single string).

0 commit comments

Comments
 (0)