Skip to content

fix(waterdata): small coherence cleanups (annotations, column order, defensiveness)#306

Draft
thodson-usgs wants to merge 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/waterdata-small-cleanups
Draft

fix(waterdata): small coherence cleanups (annotations, column order, defensiveness)#306
thodson-usgs wants to merge 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/waterdata-small-cleanups

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

Summary

Five small, low-risk cleanups from the package review — annotation drift, a cosmetic column-order inconsistency, and two latent defensive fixes.

  1. value annotation (get_latest_continuous, get_latest_daily): was int, but every other getter and the docstrings use str | Iterable[str]. The int hint also rejected the multi-value list filtering the siblings advertise.
  2. thresholds annotation (get_time_series_metadata): was int, vs float | list[float] on get_combined_metadata for the same queryable.
  3. _arrange_cols (cosmetic): the set that moves the synthetic per-record id column to the end omitted peak_id, channel_measurements_id, combined_meta_id, field_series_id — so those four getters left their id at the front, unlike daily_id/continuous_id. Added them so column layout is consistent across the parallel getters.
  4. _next_req_url: returned a falsy href ("") instead of None, contradicting its Optional[str] contract (live callers mask it with or None, so this is hardening rather than a live bug).
  5. _get_resp_data (geopandas branch): pd.json_normalize(features)["id"] raises KeyError if a feature lacks a top-level id; the non-geopandas branch already uses the defensive f.get("id"). Mirrored it.

Verification (live API)

  • get_peaks(...)peak_id is now the last column (was at the front); 11 affected getter tests pass live.
  • The annotation changes (1, 2) are type-hint only — runtime is unchanged. ruff clean.

🤖 Generated with Claude Code

…defensiveness)

Five small, low-risk fixes surfaced by the package review:

1. get_latest_continuous / get_latest_daily: `value` was annotated `int`, but
   every other getter (and the docstrings) use `str | Iterable[str]`; the `int`
   hint also rejected the multi-value list filtering the others advertise.
2. get_time_series_metadata: `thresholds` was annotated `int`, vs
   `float | list[float]` on get_combined_metadata for the same queryable.
3. _arrange_cols: the "move the synthetic per-record id column to the end" set
   omitted peak_id, channel_measurements_id, combined_meta_id, and
   field_series_id, so those four getters left their id at the front instead of
   the end like daily_id. Added them for consistent column layout.
4. _next_req_url: returned a falsy `href` ("") instead of None, contradicting
   its Optional[str] contract. Return None.
5. _get_resp_data (geopandas branch): mirror the non-geopandas branch's
   `f.get("id")` so a feature missing a top-level id yields None rather than a
   KeyError.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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