Commit 749f72e
Add StringFilter/StringList aliases; fix Copilot bugs
Adopt named type aliases so the 180 signatures across api.py read as
semantic intent ("a StringFilter / StringList / DateRange") instead of
the mechanical "str | Iterable[str] | None" busy-work. Plus four
correctness fixes from the latest Copilot pass.
types.py:
StringFilter = Optional[Union[str, Iterable[str]]]
Multi-value filter: str OR iterable of str. The runtime normalizes
iterables to list inside _get_args.
StringList = Optional[Iterable[str]]
Comma-joined list of property names. Excludes single str at the
type level because ",".join(str) would iterate characters.
api.py:
- 172 `str | Iterable[str] | None` -> `StringFilter`
- 8 `properties: ... | None` -> `properties: StringList`
- Drop the now-unused `from collections.abc import Iterable`
Correctness fixes:
1. _format_api_dates: handle `None` up front. The new `list(...)`
materialization for Series/ndarray/generator support crashed on
None even though the signature/docstring promised acceptance.
(Copilot #1)
2. _get_args: add `_LIST_ONLY_STR_PARAMS = {"properties"}` and wrap
stray single-string input into a one-element list, so
`",".join(properties)` downstream stays safe. (Copilot #3)
3. _construct_api_requests: `if bbox:` -> `if bbox is not None and
len(bbox) > 0`. The truthy check raised ValueError when bbox was
a numpy.ndarray with >1 element. Use len() instead of truthy.
(Copilot #2)
4. _NO_NORMALIZE_PARAMS: add `bbox`, `boundingBox`. These are
list[float] params; the previous runtime-type heuristic in
_get_args handled list/tuple of floats but a numpy.ndarray of
floats would have been routed through `_normalize_str_iterable`
and rejected as "elements must be strings". (Copilot #2)
Full suite 267 passed + 2 skipped + 4 deselected (flaky live-API 502s);
ruff lint + format clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7c32bea commit 749f72e
3 files changed
Lines changed: 227 additions & 189 deletions
0 commit comments