Commit 2ec0fef
fix(nwis): extend major-filter & format guards to get_stats, get_info, peaks, ratings
Same package-review bug class as the rest of this PR, in the remaining
deprecated nwis getters:
- get_stats injected `sites=sites` unconditionally, defeating
query_waterservices' major-filter check, so get_stats() (and
get_record(service="stat")) hit the network and returned a confusing
"Bad Request" instead of the documented TypeError. Inject only when given.
- get_record(service="site") forwarded sites=None into get_info, the only
getter not guarding its own injection; drop an unset `sites` there too.
- get_discharge_peaks passed format="rdb" explicitly alongside **kwargs, so
any caller-supplied `format` raised "multiple values for 'format'".
Generalize _reject_non_json_format -> _reject_unexpected_format and apply
it (json for dv/iv, rdb for peaks and stats).
- get_stats now rejects a non-RDB `format` instead of requesting it and
mis-parsing the response.
- get_ratings is per-site; with no site it issued a request that returned an
unhelpful error page. Fail fast with a clear TypeError (also covers
get_record(service="ratings")).
Adds 7 regression tests; all fail on the prior commit. Full nwis suite (57)
passes; ruff clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 0ccd573 commit 2ec0fef
2 files changed
Lines changed: 102 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | | - | |
137 | | - | |
138 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
139 | 139 | | |
140 | | - | |
141 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
| |||
293 | 295 | | |
294 | 296 | | |
295 | 297 | | |
| 298 | + | |
296 | 299 | | |
297 | 300 | | |
298 | 301 | | |
| |||
368 | 371 | | |
369 | 372 | | |
370 | 373 | | |
371 | | - | |
372 | | - | |
373 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
374 | 384 | | |
375 | 385 | | |
376 | 386 | | |
| |||
550 | 560 | | |
551 | 561 | | |
552 | 562 | | |
553 | | - | |
| 563 | + | |
554 | 564 | | |
555 | 565 | | |
556 | 566 | | |
| |||
668 | 678 | | |
669 | 679 | | |
670 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
671 | 687 | | |
672 | 688 | | |
673 | 689 | | |
| |||
737 | 753 | | |
738 | 754 | | |
739 | 755 | | |
740 | | - | |
| 756 | + | |
741 | 757 | | |
742 | 758 | | |
743 | 759 | | |
| |||
802 | 818 | | |
803 | 819 | | |
804 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
805 | 826 | | |
806 | 827 | | |
807 | 828 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
164 | 233 | | |
165 | 234 | | |
166 | 235 | | |
| |||
0 commit comments