remove now unnecessary type checking
This commit is contained in:
parent
0b97f45a72
commit
7636923b30
1 changed files with 3 additions and 18 deletions
21
recipes.py
21
recipes.py
|
@ -150,21 +150,11 @@ class PriceDB:
|
|||
|
||||
def load(self, dct: Dict[str, Any]) -> List[str]:
|
||||
issues = []
|
||||
if isinstance(dct["price"], float):
|
||||
self.price = dct["price"]
|
||||
elif isinstance(dct["price"], int):
|
||||
self.price = float(dct["price"])
|
||||
else:
|
||||
raise RuntimeError(f"{dct['price']} has to be int or float")
|
||||
self.price = dct["price"]
|
||||
|
||||
self.amount = 1.0
|
||||
if "amount" in dct:
|
||||
if isinstance(dct["amount"], float):
|
||||
self.amount = dct["amount"]
|
||||
elif isinstance(dct["amount"], int):
|
||||
self.amount = float(dct["amount"])
|
||||
else:
|
||||
raise RuntimeError(f"{dct['amount']} has to be int or float")
|
||||
self.amount = dct["amount"]
|
||||
|
||||
self.unit = None
|
||||
if "unit" in dct:
|
||||
|
@ -194,12 +184,7 @@ class IngredientInstance:
|
|||
|
||||
self.amount = self.defaultamount
|
||||
if "amount" in dct:
|
||||
if isinstance(dct["amount"], float):
|
||||
self.amount = dct["amount"]
|
||||
elif isinstance(dct["amount"], int):
|
||||
self.amount = float(dct["amount"])
|
||||
else:
|
||||
raise RuntimeError(f"{dct['amount']} has to be int or float")
|
||||
self.amount = dct["amount"]
|
||||
|
||||
self.unit = self.defaultunit
|
||||
if "unit" in dct:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue