Skip to content

Commit

Permalink
Add __iter__ to PystacItemCollection stub (#73)
Browse files Browse the repository at this point in the history
Also black-format
  • Loading branch information
gjoseph92 authored Aug 30, 2021
1 parent 3f448e7 commit 72df948
Showing 1 changed file with 7 additions and 2 deletions.
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}")

0 comments on commit 72df948

Please sign in to comment.