fix(waterdata): small coherence cleanups (annotations, column order, defensiveness)#306
Draft
thodson-usgs wants to merge 1 commit into
Draft
fix(waterdata): small coherence cleanups (annotations, column order, defensiveness)#306thodson-usgs wants to merge 1 commit into
thodson-usgs wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five small, low-risk cleanups from the package review — annotation drift, a cosmetic column-order inconsistency, and two latent defensive fixes.
valueannotation (get_latest_continuous,get_latest_daily): wasint, but every other getter and the docstrings usestr | Iterable[str]. Theinthint also rejected the multi-value list filtering the siblings advertise.thresholdsannotation (get_time_series_metadata): wasint, vsfloat | list[float]onget_combined_metadatafor the same queryable._arrange_cols(cosmetic): the set that moves the synthetic per-record id column to the end omittedpeak_id,channel_measurements_id,combined_meta_id,field_series_id— so those four getters left their id at the front, unlikedaily_id/continuous_id. Added them so column layout is consistent across the parallel getters._next_req_url: returned a falsyhref("") instead ofNone, contradicting itsOptional[str]contract (live callers mask it withor None, so this is hardening rather than a live bug)._get_resp_data(geopandas branch):pd.json_normalize(features)["id"]raisesKeyErrorif a feature lacks a top-levelid; the non-geopandas branch already uses the defensivef.get("id"). Mirrored it.Verification (live API)
get_peaks(...)→peak_idis now the last column (was at the front); 11 affected getter tests pass live.ruffclean.🤖 Generated with Claude Code