From 4845fb999ecec270ce1aa6d63a2ebc24cd1468c2 Mon Sep 17 00:00:00 2001 From: Felix Schneider Date: Sun, 26 Jan 2025 12:46:15 +0100 Subject: [PATCH] Remove UUID field from Ingredient class initialization The UUID field is now generated dynamically in the `to_dict` method instead of being set during initialization. --- source/ingredient.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/source/ingredient.py b/source/ingredient.py index 3476fd7..b8afec2 100644 --- a/source/ingredient.py +++ b/source/ingredient.py @@ -8,15 +8,10 @@ class Ingredient: name: str specification: str = None - uuid: str = None @staticmethod def from_raw_data(raw_data: dict) -> Ingredient: - return Ingredient( - name=Ingredient._get_name(raw_data), - specification=Ingredient._get_specification(raw_data), - uuid=str(uuid.uuid4()), - ) + return Ingredient(name=Ingredient._get_name(raw_data), specification=Ingredient._get_specification(raw_data)) @staticmethod def _get_name(raw_data: dict) -> str: @@ -65,4 +60,4 @@ def to_string_list(ingredients: list[Ingredient]) -> list[str]: return [ingredient.name for ingredient in ingredients] def to_dict(self) -> dict: - return {"itemId": self.name, "spec": self.specification, "uuid": self.uuid} + return {"itemId": self.name, "spec": self.specification, "uuid": str(uuid.uuid4())}