@@ -78,7 +78,7 @@ class STACVersionRange:
7878
7979 def __init__ (
8080 self ,
81- min_version : Union [str , STACVersionID ] = "0.4 .0" ,
81+ min_version : Union [str , STACVersionID ] = "0.8 .0" ,
8282 max_version : Optional [Union [str , STACVersionID ]] = None ,
8383 ):
8484 if isinstance (min_version , str ):
@@ -180,17 +180,34 @@ def identify_stac_object_type(
180180 Args:
181181 json_dict : The dict of JSON to identify.
182182 """
183- # Try to identify using 'type' property, if present
184- if "type" in json_dict :
185- # Try to find 'type' property in known STACObjectType values
186- for t in pystac .STACObjectType :
187- if json_dict ["type" ].lower () == t .value .lower ():
188- return t
189-
183+ stac_version = (
184+ STACVersionID (json_dict ["stac_version" ])
185+ if "stac_version" in json_dict
186+ else None
187+ )
190188 obj_type = json_dict .get ("type" )
191189
190+ # Try to identify using 'type' property for v1.0.0-rc.1 and higher
191+ introduced_type_attribute = STACVersionID ("1.0.0-rc.1" )
192+ if stac_version is not None and stac_version >= introduced_type_attribute :
193+
194+ # Since v1.0.0-rc.1 requires a "type" field for all STAC objects, any object
195+ # that is missing this attribute is not a valid STAC object.
196+ if obj_type is None :
197+ return None
198+
199+ # Try to match the "type" attribute
200+ if obj_type == pystac .STACObjectType .CATALOG :
201+ return pystac .STACObjectType .CATALOG
202+ elif obj_type == pystac .STACObjectType .COLLECTION :
203+ return pystac .STACObjectType .COLLECTION
204+ elif obj_type == pystac .STACObjectType .ITEM :
205+ return pystac .STACObjectType .ITEM
206+ else :
207+ return None
208+
192209 # For pre-1.0 objects for version 0.8.* or later 'stac_version' must be present
193- if " stac_version" in json_dict :
210+ if stac_version is not None :
194211 # Pre-1.0 STAC objects with 'type' == "Feature" are Items
195212 if obj_type == "Feature" :
196213 return pystac .STACObjectType .ITEM
0 commit comments