This commit is contained in:
Emi Vasilek 2023-11-06 23:51:46 +01:00
parent 009a556c32
commit 15ce2f152f
2 changed files with 13 additions and 7 deletions

6
.pylintrc Normal file
View file

@ -0,0 +1,6 @@
[messages control]
disable=
missing-module-docstring,
missing-class-docstring,
missing-function-docstring,
too-few-public-methods

View file

@ -72,7 +72,7 @@ class Unit(Element):
for convdct in dct["conversions"]:
if "from" in dct["conversions"]:
raise RuntimeError(
f"conversions in units.yaml cannot have a from field, it is automatically assigned from the unit name"
"conversions in units.yaml cannot have a from field, it is automatically assigned from the unit name"
)
convdct["from"] = self["name"]
conversion = Conversion(self.ctx, convdct)
@ -156,7 +156,7 @@ class PriceDB(Element):
if "unit" in dct:
unitstr = dct["unit"]
self["unit"] = self.ctx.units.get(unitstr)
if self["unit"] == None:
if self["unit"] is None:
self.ctx.issues.append(f"unknown unit {unitstr}")
else:
self["unit"] = None
@ -165,7 +165,7 @@ class PriceDB(Element):
class IngredientInstance(Element):
def load(self, dct: Dict[str, Any]) -> None:
self["ingredient"] = self.ctx.ingredients.get(dct["name"])
if self["ingredient"] == None:
if self["ingredient"] is None:
self.ctx.issues.append(f"unknown ingredient {dct['name']}")
if "amount" not in dct:
@ -174,7 +174,7 @@ class IngredientInstance(Element):
if "unit" in dct:
unitstr = dct["unit"]
self["unit"] = self.ctx.units.get(unitstr)
if self["unit"] == None:
if self["unit"] is None:
self.ctx.issues.append("unknown unit {unitstr}")
else:
self["unit"] = None
@ -222,12 +222,12 @@ class Builder:
def numprint(input: int) -> str:
out = str(input)
if out.endswith(".0"):
out = out.split(".")[0]
return out.split(".", maxsplit=1)[0]
if out == "0.5":
return "1/2"
elif out == "0.25":
if out == "0.25":
return "1/4"
elif out == "0.75":
if out == "0.75":
return "3/4"
return out