Skip to content
Snippets Groups Projects
Commit 1700b68a authored by Hock, Benedikt's avatar Hock, Benedikt
Browse files

Add typing and kwargs

parent 5002eee9
No related branches found
No related tags found
No related merge requests found
......@@ -7,12 +7,15 @@ from typing import Any, Union, Literal, TypedDict, TypeVar, Type, List, Optional
class LegoItem:
def __init__(self, item_number: int, mass: float, delivery_time: int) -> None:
def __init__(self, item_number: int, mass: float, delivery_time: int, **kwargs) -> None:
# , *args, **kwargs not handling additional/optional specs right now
self.id = uuid.uuid4()
self.item_number = item_number
self.mass = mass
self.delivery_time = delivery_time
self.id: uuid.UUID = uuid.uuid4()
self.properties: dict = kwargs
self.item_number: int = item_number
self.mass: float = mass
self.delivery_time: int = delivery_time
# TODO: Set parent directly and not via id? This would allow for easier traversal of the tree
# Currently there is no way to search for parts and components in tree by id.
self.parent_id = None # This will be set when added to a component
def __str__(self):
......@@ -22,6 +25,8 @@ class LegoItem:
f"parent_id={self.parent_id})"
)
def __repr__(self):
return f"Lego Item [{self.id}]"
class LegoComponent:
def __init__(self, items=None | LegoItem | list[LegoItem],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment