py2puml
py2puml copied to clipboard
handle attribute default value
using the defaults attribute of the constructor method should help
getattr(definition_type.__init__, '__defaults__', None)
- see this example for the way to display attribute with a default value: https://stackoverflow.com/a/36323868
default values of named tuples can be handled with the _fields_defaults attribute (see #5)
for p, v in inspect.signature(definition_type.__init__).parameters.items():
will give the defaults and types of the parameters of the constructor.
v.default is the default value. v.default will be inspect.Parameter.empty if the default value is not given.
v.annotation is the type of the parameter. v.annotation will be inspect.Parameter.empty if the type of parameter is not given.