Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def from_json(cls, json_dict: Dict) -> 'ItemProperties':
"""Construct ItemProperties object from dictionary/JSON."""
# Convert the dictionary under the 'equipment' key into ItemEquipment.
if json_dict.get("equipable_by_player"):
equipment = json_dict.pop("equipment")
json_dict["equipment"] = ItemEquipment(**equipment)
# Convert the dictionary under the 'weapon' key into ItemWeapon.
if json_dict.get("weapon"):
weapon = json_dict.pop("weapon")
json_dict["weapon"] = ItemWeapon(**weapon)
return cls(**json_dict)
equipable_weapon: bool
cost: int
lowalch: int
highalch: int
weight: Optional[float]
buy_limit: Optional[int]
quest_item: bool
release_date: Optional[str]
duplicate: bool
examine: Optional[str]
icon: str
wiki_name: Optional[str]
wiki_url: Optional[str]
wiki_exchange: Optional[str]
equipment: Optional[ItemEquipment] = None
weapon: Optional[ItemWeapon] = None
@classmethod
def from_json(cls, json_dict: Dict) -> 'ItemProperties':
"""Construct ItemProperties object from dictionary/JSON."""
# Convert the dictionary under the 'equipment' key into ItemEquipment.
if json_dict.get("equipable_by_player"):
equipment = json_dict.pop("equipment")
json_dict["equipment"] = ItemEquipment(**equipment)
# Convert the dictionary under the 'weapon' key into ItemWeapon.
if json_dict.get("weapon"):
weapon = json_dict.pop("weapon")
json_dict["weapon"] = ItemWeapon(**weapon)
return cls(**json_dict)