Data Classes
Dependency + Dataclasses¶
You can use the built-in dataclasses with Dependency without a problem. Just ensure all fields are optional (ie: they all have default values), so they are not required when creating/init'ing the object.
You can also provide a __post_init__ method on your Dependency
subclass to help you initialize the values into a good default state
(a standard feature of dataclasses).
The purpose to enable lazily creation of the Dependency object the very first time it's asked for.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Last update:
2023-04-15