D901: changelog: use a Factory for default value for files
This revision was automatically updated to reflect the committed changes. Closed by commit rHG50474f0b3f1b: changelog: use a Factory for default value for files (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D901?vs=2322=2398 REVISION DETAIL https://phab.mercurial-scm.org/D901 AFFECTED FILES mercurial/changelog.py CHANGE DETAILS diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -151,7 +151,7 @@ manifest = attr.ib(default=nullid) user = attr.ib(default='') date = attr.ib(default=(0, 0)) -files = attr.ib(default=[]) +files = attr.ib(default=attr.Factory(list)) description = attr.ib(default='') class changelogrevision(object): To: indygreg, #hg-reviewers, lothiraldan Cc: lothiraldan, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D901: changelog: use a Factory for default value for files
lothiraldan accepted this revision. lothiraldan added a comment. Looks good to me and seems coherent with what attr documentation recommends. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D901 To: indygreg, #hg-reviewers, lothiraldan Cc: lothiraldan, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D901: changelog: use a Factory for default value for files
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION 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. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D901 AFFECTED FILES mercurial/changelog.py CHANGE DETAILS diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -151,7 +151,7 @@ manifest = attr.ib(default=nullid) user = attr.ib(default='') date = attr.ib(default=(0, 0)) -files = attr.ib(default=[]) +files = attr.ib(default=attr.Factory(list)) description = attr.ib(default='') class changelogrevision(object): To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel