Skip to content

Commit c206c0c

Browse files
thodson-usgsclaude
andcommitted
Apply _normalize_str_iterable to every multi-value string parameter
Extracts the type-and-iterable normalization out of _check_monitoring_location_id into a reusable helper, then wires it into every public waterdata getter at every multi-value string parameter. Closes the gap noted in PR review: previously only `monitoring_location_id` accepted pd.Series / np.ndarray / tuple; other params (parameter_code, statistic_id, state_name, etc.) still silently str-serialized non-list iterables into the request. Changes: - dataretrieval/waterdata/utils.py: new `_normalize_str_iterable(value, param_name)` does the None / str / non-Mapping-Iterable dispatch and per-element type check. `_check_monitoring_location_id` now wraps it and adds the AGENCY-ID hyphen check, which remains monitoring_location_id-specific. - dataretrieval/waterdata/api.py: 153 normalization calls inserted across 11 public functions (get_daily, get_continuous, get_monitoring_locations, get_time_series_metadata, get_latest_continuous, get_latest_daily, get_field_measurements, get_samples, get_stats_por, get_stats_date_range, get_channel). 170 type annotations widened from `str | list[str] | None` / `list[str] | None` to `str | Iterable[str] | None`. Added Iterable import and `_normalize_str_iterable` to imports. Excluded (kept as-is): time-range params (time, last_modified, begin, end, begin_utc, end_utc, datetime) — these have special semantics in _format_api_dates (single-string or two-element range). Out of scope; users who need iterable support there can `.tolist()`. - tests/waterdata_test.py: new TestNormalizeStrIterable class with 10 tests covering str / list / tuple / pd.Series / pd.Index / np.ndarray acceptance, plus int / dict rejection, plus an integration check (mock.patch on get_ogc_data) confirming that passing pd.Series for parameter_code arrives at the inner call as a list, not a stringified Series. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 129229d commit c206c0c

3 files changed

Lines changed: 555 additions & 205 deletions

File tree

0 commit comments

Comments
 (0)