Skip to content

Commit a0a1735

Browse files
authored
Fix get_items without ids (#579)
* fix: get_items without ids Passing empty list to `search` has different semantics than `None`. * fix: disallow empty lists in ItemSearch * fix: wayy overengineer _format_ids
1 parent 93742ad commit a0a1735

File tree

4 files changed

+544
-7
lines changed

4 files changed

+544
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1414

1515
### Fixed
1616

17-
- Updated `get_items` signatures for PySTAC v1.8 [#559](https://github.com/stac-utils/pystac-client/pull/559)
17+
- Updated `get_items` signatures for PySTAC v1.8 [#559](https://github.com/stac-utils/pystac-client/pull/559), [#579](https://github.com/stac-utils/pystac-client/pull/579)
1818

1919
## [v0.7.2] - 2023-06-23
2020

pystac_client/item_search.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,18 @@ def _format(c: Any) -> Collections:
550550

551551
@staticmethod
552552
def _format_ids(value: Optional[IDsLike]) -> Optional[IDs]:
553-
if value is None:
553+
if value is None or isinstance(value, (tuple, list)) and not value:
554+
# We can't just check for truthiness here because of the Iterator[str] case
554555
return None
555-
556-
if isinstance(value, str):
557-
return tuple(value.split(","))
558-
559-
return tuple(value)
556+
elif isinstance(value, str):
557+
# We could check for str in the first branch, but then we'd be checking
558+
# for str twice #microoptimizations
559+
if value:
560+
return tuple(value.split(","))
561+
else:
562+
return None
563+
else:
564+
return tuple(value)
560565

561566
def _format_sortby(self, value: Optional[SortbyLike]) -> Optional[Sortby]:
562567
if value is None:

0 commit comments

Comments
 (0)