Commit 459f391
refactor(waterdata): module coherence — unify id extraction and empty-frame idiom
Two behavior-preserving coherence fixes in the OGC response path (live
get_daily/get_continuous/get_monitoring_locations bit-for-bit unchanged; 184
tests + README/time-conventions doctests pass):
- `_get_resp_data`'s geopandas branch now extracts `id` the same way as its own
non-geopandas branch — `[f.get("id") for f in features]` — instead of a
second full `pd.json_normalize(features)["id"]`. Drops a redundant
whole-feature normalize pass and is None-safe (the json_normalize form
KeyErrors on id-less features); the two halves of the function now match.
- Add `_empty_frame(geopd)` and call it at the four sites that spelled out
`gpd.GeoDataFrame() if geopd else pd.DataFrame()`, centralizing the
"empty page, preserve the geo/plain type" invariant that was folklore
repeated across the OGC and stats parsers.
Deferred as a coherence backlog (out of scope for this bugfix PR — mostly
public-API or behavior changes): unifying error handling across the
samples/codes/ratings direct-httpx callers (raw raise_for_status vs typed
_raise_for_non_200), the ssl_check exposure asymmetry, get_codes returning a
bare DataFrame, get_stats_data's inline finalizer vs the OGC closure, the
samples GET-tail duplication, and assorted api.py docstring/naming drift.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent a37cb5c commit 459f391
1 file changed
Lines changed: 20 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
725 | 736 | | |
726 | 737 | | |
727 | 738 | | |
| |||
768 | 779 | | |
769 | 780 | | |
770 | 781 | | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
776 | 785 | | |
777 | 786 | | |
778 | 787 | | |
| |||
781 | 790 | | |
782 | 791 | | |
783 | 792 | | |
784 | | - | |
| 793 | + | |
785 | 794 | | |
786 | 795 | | |
787 | 796 | | |
| |||
798 | 807 | | |
799 | 808 | | |
800 | 809 | | |
801 | | - | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
802 | 813 | | |
803 | 814 | | |
804 | 815 | | |
| |||
1361 | 1372 | | |
1362 | 1373 | | |
1363 | 1374 | | |
1364 | | - | |
| 1375 | + | |
1365 | 1376 | | |
1366 | 1377 | | |
1367 | 1378 | | |
| |||
1372 | 1383 | | |
1373 | 1384 | | |
1374 | 1385 | | |
1375 | | - | |
| 1386 | + | |
1376 | 1387 | | |
1377 | 1388 | | |
1378 | 1389 | | |
| |||
0 commit comments