Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quality-kpi
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stumpe, Marius
quality-kpi
Commits
1700b68a
Commit
1700b68a
authored
2 years ago
by
Hock, Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
Add typing and kwargs
parent
5002eee9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
functions/lego_classes.py
+10
-5
10 additions, 5 deletions
functions/lego_classes.py
with
10 additions
and
5 deletions
functions/lego_classes.py
+
10
−
5
View file @
1700b68a
...
...
@@ -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
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment