Skip to content

Commit

Permalink
Fix get_items without ids (#579)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gadomski authored Aug 21, 2023
1 parent 93742ad commit a0a1735
Show file tree
Hide file tree
Showing 4 changed files with 544 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

- Updated `get_items` signatures for PySTAC v1.8 [#559](https://github.com/stac-utils/pystac-client/pull/559)
- 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)

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

Expand Down
17 changes: 11 additions & 6 deletions pystac_client/item_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,18 @@ def _format(c: Any) -> Collections:

@staticmethod
def _format_ids(value: Optional[IDsLike]) -> Optional[IDs]:
if value is None:
if value is None or isinstance(value, (tuple, list)) and not value:
# We can't just check for truthiness here because of the Iterator[str] case
return None

if isinstance(value, str):
return tuple(value.split(","))

return tuple(value)
elif isinstance(value, str):
# We could check for str in the first branch, but then we'd be checking
# for str twice #microoptimizations
if value:
return tuple(value.split(","))
else:
return None
else:
return tuple(value)

def _format_sortby(self, value: Optional[SortbyLike]) -> Optional[Sortby]:
if value is None:
Expand Down
Loading

0 comments on commit a0a1735

Please sign in to comment.