Skip to content

fix(waterdata)!: return (df, BaseMetadata) from get_codes#301

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/waterdata-get-codes-metadata
Jun 1, 2026
Merged

fix(waterdata)!: return (df, BaseMetadata) from get_codes#301
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/waterdata-get-codes-metadata

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

Problem

get_codes is the only public waterdata getter that returns a bare DataFrame instead of the module-wide (DataFrame, BaseMetadata) tuple. So the universal idiom every other getter supports —

df, md = waterdata.get_codes("samplemedia")   # ValueError: too many values to unpack

— breaks, even though get_codes already builds response and calls _raise_for_non_200(response) (the metadata is in hand, just discarded).

Fix

Return (df, BaseMetadata(response)), matching get_reference_table and every other getter.

⚠️ Breaking change. Existing callers doing df = get_codes(...) must switch to df, _ = get_codes(...). Opened as a draft so maintainers can decide whether to take the break now or stage a deprecation. get_codes is a relatively new waterdata addition, so the blast radius should be small.

Verification (live API)

df, md = waterdata.get_codes("samplemedia")
# is 2-tuple: True · df non-empty: True · md.url set: True · md.query_time present: True

ruff clean.

🤖 Generated with Claude Code

Every other public waterdata getter returns a (DataFrame, BaseMetadata)
tuple, but get_codes returned a bare DataFrame, so the module's universal
idiom `df, md = waterdata.get_codes(...)` raised an unpack error. It already
builds `response` (and calls _raise_for_non_200), so the metadata was in hand
and discarded.

BREAKING: callers doing `df = get_codes(...)` must switch to
`df, _ = get_codes(...)`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thodson-usgs thodson-usgs marked this pull request as ready for review June 1, 2026 03:16
@thodson-usgs thodson-usgs merged commit d3779de into DOI-USGS:main Jun 1, 2026
8 checks passed
@thodson-usgs thodson-usgs deleted the fix/waterdata-get-codes-metadata branch June 1, 2026 03:16
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