pylint
This commit is contained in:
parent
009a556c32
commit
15ce2f152f
2 changed files with 13 additions and 7 deletions
6
.pylintrc
Normal file
6
.pylintrc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[messages control]
|
||||||
|
disable=
|
||||||
|
missing-module-docstring,
|
||||||
|
missing-class-docstring,
|
||||||
|
missing-function-docstring,
|
||||||
|
too-few-public-methods
|
14
recipes.py
14
recipes.py
|
@ -72,7 +72,7 @@ class Unit(Element):
|
||||||
for convdct in dct["conversions"]:
|
for convdct in dct["conversions"]:
|
||||||
if "from" in dct["conversions"]:
|
if "from" in dct["conversions"]:
|
||||||
raise RuntimeError(
|
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"]
|
convdct["from"] = self["name"]
|
||||||
conversion = Conversion(self.ctx, convdct)
|
conversion = Conversion(self.ctx, convdct)
|
||||||
|
@ -156,7 +156,7 @@ class PriceDB(Element):
|
||||||
if "unit" in dct:
|
if "unit" in dct:
|
||||||
unitstr = dct["unit"]
|
unitstr = dct["unit"]
|
||||||
self["unit"] = self.ctx.units.get(unitstr)
|
self["unit"] = self.ctx.units.get(unitstr)
|
||||||
if self["unit"] == None:
|
if self["unit"] is None:
|
||||||
self.ctx.issues.append(f"unknown unit {unitstr}")
|
self.ctx.issues.append(f"unknown unit {unitstr}")
|
||||||
else:
|
else:
|
||||||
self["unit"] = None
|
self["unit"] = None
|
||||||
|
@ -165,7 +165,7 @@ class PriceDB(Element):
|
||||||
class IngredientInstance(Element):
|
class IngredientInstance(Element):
|
||||||
def load(self, dct: Dict[str, Any]) -> None:
|
def load(self, dct: Dict[str, Any]) -> None:
|
||||||
self["ingredient"] = self.ctx.ingredients.get(dct["name"])
|
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']}")
|
self.ctx.issues.append(f"unknown ingredient {dct['name']}")
|
||||||
|
|
||||||
if "amount" not in dct:
|
if "amount" not in dct:
|
||||||
|
@ -174,7 +174,7 @@ class IngredientInstance(Element):
|
||||||
if "unit" in dct:
|
if "unit" in dct:
|
||||||
unitstr = dct["unit"]
|
unitstr = dct["unit"]
|
||||||
self["unit"] = self.ctx.units.get(unitstr)
|
self["unit"] = self.ctx.units.get(unitstr)
|
||||||
if self["unit"] == None:
|
if self["unit"] is None:
|
||||||
self.ctx.issues.append("unknown unit {unitstr}")
|
self.ctx.issues.append("unknown unit {unitstr}")
|
||||||
else:
|
else:
|
||||||
self["unit"] = None
|
self["unit"] = None
|
||||||
|
@ -222,12 +222,12 @@ class Builder:
|
||||||
def numprint(input: int) -> str:
|
def numprint(input: int) -> str:
|
||||||
out = str(input)
|
out = str(input)
|
||||||
if out.endswith(".0"):
|
if out.endswith(".0"):
|
||||||
out = out.split(".")[0]
|
return out.split(".", maxsplit=1)[0]
|
||||||
if out == "0.5":
|
if out == "0.5":
|
||||||
return "1/2"
|
return "1/2"
|
||||||
elif out == "0.25":
|
if out == "0.25":
|
||||||
return "1/4"
|
return "1/4"
|
||||||
elif out == "0.75":
|
if out == "0.75":
|
||||||
return "3/4"
|
return "3/4"
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue