Commit fa8387e
Widen _check_monitoring_location_id to accept iterables of strings
The previous `(str, list)` isinstance check rejected legitimate inputs:
tuple, pandas.Series, pandas.Index, numpy.ndarray, generators. Pre-fix
these would round-trip through requests and either work (tuple) or
silently break the URL (numpy/pandas). Post-fix the function:
- Accepts any non-string iterable whose elements are strings
- Materializes the iterable to a list so downstream comma-join /
POST-CQL2 logic in _construct_api_requests keeps working uniformly
- Returns the (possibly-normalized) value, so callers reassign:
monitoring_location_id = _check_monitoring_location_id(monitoring_location_id)
- Rejects Mapping (e.g. dict) explicitly — iterating a dict yields
keys, which is a footgun
Live-verified against api.waterdata.usgs.gov: passing tuple, pd.Series,
pd.Index, and np.ndarray of "USGS-01646500" all return 3 rows for the
2024-06-01/2024-06-03 window. Passing pd.Series([1646500]) raises
TypeError("monitoring_location_id elements must be strings, not int...")
before any network call.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c6b262e commit fa8387e
3 files changed
Lines changed: 93 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
705 | | - | |
| 705 | + | |
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
| |||
926 | 926 | | |
927 | 927 | | |
928 | 928 | | |
929 | | - | |
| 929 | + | |
930 | 930 | | |
931 | 931 | | |
932 | 932 | | |
| |||
1106 | 1106 | | |
1107 | 1107 | | |
1108 | 1108 | | |
1109 | | - | |
| 1109 | + | |
1110 | 1110 | | |
1111 | 1111 | | |
1112 | 1112 | | |
| |||
1288 | 1288 | | |
1289 | 1289 | | |
1290 | 1290 | | |
1291 | | - | |
| 1291 | + | |
1292 | 1292 | | |
1293 | 1293 | | |
1294 | 1294 | | |
| |||
1469 | 1469 | | |
1470 | 1470 | | |
1471 | 1471 | | |
1472 | | - | |
| 1472 | + | |
1473 | 1473 | | |
1474 | 1474 | | |
1475 | 1475 | | |
| |||
1925 | 1925 | | |
1926 | 1926 | | |
1927 | 1927 | | |
1928 | | - | |
| 1928 | + | |
1929 | 1929 | | |
1930 | 1930 | | |
1931 | 1931 | | |
| |||
2055 | 2055 | | |
2056 | 2056 | | |
2057 | 2057 | | |
2058 | | - | |
| 2058 | + | |
2059 | 2059 | | |
2060 | 2060 | | |
2061 | 2061 | | |
| |||
2228 | 2228 | | |
2229 | 2229 | | |
2230 | 2230 | | |
2231 | | - | |
| 2231 | + | |
2232 | 2232 | | |
2233 | 2233 | | |
2234 | 2234 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
1155 | 1156 | | |
1156 | 1157 | | |
1157 | 1158 | | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
| 1159 | + | |
| 1160 | + | |
1162 | 1161 | | |
1163 | 1162 | | |
1164 | 1163 | | |
1165 | | - | |
1166 | | - | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
1167 | 1176 | | |
1168 | 1177 | | |
1169 | 1178 | | |
1170 | 1179 | | |
1171 | | - | |
| 1180 | + | |
| 1181 | + | |
1172 | 1182 | | |
1173 | | - | |
1174 | | - | |
| 1183 | + | |
| 1184 | + | |
1175 | 1185 | | |
1176 | 1186 | | |
1177 | | - | |
| 1187 | + | |
1178 | 1188 | | |
1179 | | - | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
1180 | 1196 | | |
1181 | | - | |
| 1197 | + | |
1182 | 1198 | | |
1183 | 1199 | | |
1184 | 1200 | | |
1185 | 1201 | | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | 1202 | | |
1193 | 1203 | | |
1194 | 1204 | | |
1195 | | - | |
| 1205 | + | |
1196 | 1206 | | |
1197 | 1207 | | |
1198 | 1208 | | |
| |||
1202 | 1212 | | |
1203 | 1213 | | |
1204 | 1214 | | |
| 1215 | + | |
| 1216 | + | |
1205 | 1217 | | |
1206 | 1218 | | |
1207 | 1219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
389 | 390 | | |
390 | 391 | | |
391 | 392 | | |
392 | | - | |
393 | | - | |
| 393 | + | |
| 394 | + | |
394 | 395 | | |
395 | 396 | | |
396 | 397 | | |
397 | | - | |
| 398 | + | |
| 399 | + | |
398 | 400 | | |
399 | 401 | | |
400 | 402 | | |
401 | | - | |
| 403 | + | |
402 | 404 | | |
403 | 405 | | |
404 | 406 | | |
| |||
425 | 427 | | |
426 | 428 | | |
427 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
428 | 476 | | |
429 | 477 | | |
430 | 478 | | |
| |||
0 commit comments