The Item.from_dict method uses the dictionary "pop" method for retrieving most fields from the source dict, resulting in a KeyError if they don't exist.
The conceptual issue here is that from_dict doesn't allow the creation on an invalid Item from an invalid JSON/dict representation, whereas manually invoking the init method of Item is typed to and does allow the creation on invalid items:
def __init__(
self,
id: str,
geometry: Optional[Dict[str, Any]],
bbox: Optional[List[float]],
datetime: Optional[Datetime],
properties: Dict[str, Any],
stac_extensions: Optional[List[str]] = None,
href: Optional[str] = None,
collection: Optional[Union[str, Collection]] = None,
extra_fields: Optional[Dict[str, Any]] = None,
If the from_dict method is intended to disallow the creation of an Item from an invalid dict representation, it should throw a specific exception to this effect, not the accidental and non-contextualize KeyError.
The Item.from_dict method uses the dictionary "pop" method for retrieving most fields from the source dict, resulting in a KeyError if they don't exist.
The conceptual issue here is that from_dict doesn't allow the creation on an invalid Item from an invalid JSON/dict representation, whereas manually invoking the init method of Item is typed to and does allow the creation on invalid items:
If the from_dict method is intended to disallow the creation of an Item from an invalid dict representation, it should throw a specific exception to this effect, not the accidental and non-contextualize KeyError.