11"""STAC types."""
22
3- import sys
4- from typing import Any , Dict , List , Literal , Optional , Union
3+ from typing import Any , Dict , List , Literal , Union
54
65from stac_pydantic .shared import BBox
7-
8- # Avoids a Pydantic error:
9- # TypeError: You should use `typing_extensions.TypedDict` instead of
10- # `typing.TypedDict` with Python < 3.12.0. Without it, there is no way to
11- # differentiate required and optional fields when subclassed.
12- if sys .version_info < (3 , 12 , 0 ):
13- from typing_extensions import TypedDict
14- else :
15- from typing import TypedDict
6+ from typing_extensions import NotRequired , TypedDict
167
178NumType = Union [float , int ]
189
1910
20- class Catalog (TypedDict , total = False ):
11+ class Catalog (TypedDict ):
2112 """STAC Catalog."""
2213
2314 type : str
2415 stac_version : str
25- stac_extensions : Optional [List [str ]]
16+ stac_extensions : NotRequired [List [str ]]
2617 id : str
27- title : Optional [str ]
18+ title : NotRequired [str ]
2819 description : str
2920 links : List [Dict [str , Any ]]
3021
3122
32- class LandingPage (Catalog , total = False ):
23+ class LandingPage (Catalog ):
3324 """STAC Landing Page."""
3425
3526 conformsTo : List [str ]
@@ -41,7 +32,7 @@ class Conformance(TypedDict):
4132 conformsTo : List [str ]
4233
4334
44- class Collection (Catalog , total = False ):
35+ class Collection (Catalog ):
4536 """STAC Collection."""
4637
4738 keywords : List [str ]
@@ -52,12 +43,12 @@ class Collection(Catalog, total=False):
5243 assets : Dict [str , Any ]
5344
5445
55- class Item (TypedDict , total = False ):
46+ class Item (TypedDict ):
5647 """STAC Item."""
5748
5849 type : Literal ["Feature" ]
5950 stac_version : str
60- stac_extensions : Optional [List [str ]]
51+ stac_extensions : NotRequired [List [str ]]
6152 id : str
6253 geometry : Dict [str , Any ]
6354 bbox : BBox
@@ -67,22 +58,22 @@ class Item(TypedDict, total=False):
6758 collection : str
6859
6960
70- class ItemCollection (TypedDict , total = False ):
61+ class ItemCollection (TypedDict ):
7162 """STAC Item Collection."""
7263
7364 type : Literal ["FeatureCollection" ]
7465 features : List [Item ]
7566 links : List [Dict [str , Any ]]
76- numberMatched : Optional [int ]
77- numberReturned : Optional [int ]
67+ numberMatched : NotRequired [int ]
68+ numberReturned : NotRequired [int ]
7869
7970
80- class Collections (TypedDict , total = False ):
71+ class Collections (TypedDict ):
8172 """All collections endpoint.
8273 https://github.com/radiantearth/stac-api-spec/tree/master/collections
8374 """
8475
8576 collections : List [Collection ]
8677 links : List [Dict [str , Any ]]
87- numberMatched : Optional [int ] = None
88- numberReturned : Optional [int ] = None
78+ numberMatched : NotRequired [int ]
79+ numberReturned : NotRequired [int ]
0 commit comments