From 15ce2f152ff27726bb69b4f698cc4cd7a4cc6c3f Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Mon, 6 Nov 2023 23:51:46 +0100 Subject: [PATCH] pylint --- .pylintrc | 6 ++++++ recipes.py | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..4ff7ab7 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,6 @@ +[messages control] +disable= + missing-module-docstring, + missing-class-docstring, + missing-function-docstring, + too-few-public-methods \ No newline at end of file diff --git a/recipes.py b/recipes.py index 8dfe898..ec60273 100644 --- a/recipes.py +++ b/recipes.py @@ -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