Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __iter__ to PystacItemCollection stub #73

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions stackstac/stac_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ class PystacCatalog:
def get_all_items(self) -> Iterator[PystacItem]:
...


# pystac 1.0
try:
from pystac import ItemCollection as PystacItemCollection
except ImportError:

class PystacItemCollection:
features: List[PystacItem]

def __iter__(self) -> Iterator[PystacItem]:
...


class EOBand(TypedDict, total=False):
name: str
Expand Down Expand Up @@ -151,8 +156,8 @@ def items_to_plain(items: Union[ItemCollectionIsh, ItemIsh]) -> ItemSequence:
# which can handle each object type, preventing the need for this sort of copying.
if isinstance(items, PystacCatalog):
return [item.to_dict() for item in items.get_all_items()]

if isinstance(items, PystacItemCollection):
return [item.to_dict() for item in items]

raise TypeError(f"Unrecognized STAC collection type {type(items)}: {items!r}")