This is an archive of the discontinued Mercurial Phabricator instance.

changelog: use a Factory for default value for files
ClosedPublic

Authored by indygreg on Oct 2 2017, 6:05 AM.

Details

Summary

The default value is compiled into the generated type. This means
that default values are shared between instances. For immutable types
like bool, str, int, and tuple, this is fine. But for mutable types
like list and dict, we need to use attr.Factory() to instantiate a
new instance of the default for each object.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Oct 2 2017, 6:05 AM
lothiraldan accepted this revision.Oct 2 2017, 1:21 PM
lothiraldan added a subscriber: lothiraldan.

Looks good to me and seems coherent with what attr documentation recommends.

This revision was automatically updated to reflect the committed changes.