|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import warnings |
4 | | -from collections.abc import Iterable |
| 4 | +from collections.abc import Iterable, Sequence |
5 | 5 | from copy import deepcopy |
6 | 6 | from datetime import datetime, timezone |
7 | 7 | from typing import ( |
@@ -71,7 +71,7 @@ class SpatialExtent: |
71 | 71 |
|
72 | 72 | def __init__( |
73 | 73 | self, |
74 | | - bboxes: Bboxes | list[float | int], |
| 74 | + bboxes: Bboxes | Sequence[float | int], |
75 | 75 | extra_fields: dict[str, Any] | None = None, |
76 | 76 | ) -> None: |
77 | 77 | if not isinstance(bboxes, list): |
@@ -199,7 +199,7 @@ class TemporalExtent: |
199 | 199 |
|
200 | 200 | def __init__( |
201 | 201 | self, |
202 | | - intervals: TemporalIntervals | list[datetime | None], |
| 202 | + intervals: TemporalIntervals | Sequence[datetime | None], |
203 | 203 | extra_fields: dict[str, Any] | None = None, |
204 | 204 | ): |
205 | 205 | if not isinstance(intervals, list): |
@@ -652,7 +652,17 @@ def from_dict( |
652 | 652 | id = d.pop("id") |
653 | 653 | description = d.pop("description") |
654 | 654 | license = d.pop("license") |
655 | | - extent = Extent.from_dict(d.pop("extent")) |
| 655 | + if extent_dict := d.pop("extent", None): |
| 656 | + extent = Extent.from_dict(extent_dict) |
| 657 | + else: |
| 658 | + warnings.warn( |
| 659 | + "Collection is missing extent, setting default spatial and " |
| 660 | + "temporal extents" |
| 661 | + ) |
| 662 | + extent = Extent( |
| 663 | + spatial=SpatialExtent([-90, -180, 90, 180]), |
| 664 | + temporal=TemporalExtent([None, None]), |
| 665 | + ) |
656 | 666 | title = d.pop("title", None) |
657 | 667 | stac_extensions = d.pop("stac_extensions", None) |
658 | 668 | keywords = d.pop("keywords", None) |
|
0 commit comments