Is your feature request related to a problem? Please describe.
If a property is created with a mutable default (e.g. myprop: dict = lt.property(default={"foo":"bar"})) then it's easy for Things to share state unintentionally.
Describe the solution you'd like
If a default value is set to a mutable object (e.g. a dict or list) it should warn about this and suggest using a default factory instead.
Describe alternatives you've considered
Automatically calling deepcopy() would be another potential solution, but I think it exposes us to the possibility of hard-to-debug edge cases, rather than just encouraging accepted best practice (default factories) in downstream code.
Additional context
This caused some head scratching in OFM#750 and OFM#751.
Is your feature request related to a problem? Please describe.
If a property is created with a mutable default (e.g.
myprop: dict = lt.property(default={"foo":"bar"})) then it's easy for Things to share state unintentionally.Describe the solution you'd like
If a default value is set to a mutable object (e.g. a
dictorlist) it should warn about this and suggest using a default factory instead.Describe alternatives you've considered
Automatically calling
deepcopy()would be another potential solution, but I think it exposes us to the possibility of hard-to-debug edge cases, rather than just encouraging accepted best practice (default factories) in downstream code.Additional context
This caused some head scratching in OFM#750 and OFM#751.