Skip to content

Commit

Permalink
Remove UUID field from Ingredient class initialization
Browse files Browse the repository at this point in the history
The UUID field is now generated dynamically in the `to_dict` method instead of being set during initialization.
  • Loading branch information
felixschndr committed Jan 26, 2025
1 parent 73ae088 commit 4845fb9
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions source/ingredient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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())}

0 comments on commit 4845fb9

Please sign in to comment.