This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gianni
Recipients CCLDArjun, eric.smith, gianni
Date 2021-07-24.06:45:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627109159.36.0.509582449495.issue44674@roundup.psfhosted.org>
In-reply-to
Content
@Arjun - this is about default values (See the bug description - Using a frozendict as a default value)

Try this:

from frozendict import frozendict
from dataclasses import dataclass

@dataclass
class A:
    a: frozendict = frozendict(a=1)

This used to work until frozendict became a subclass of dict.

Perhaps another fix is to convert any dict to a frozendict? Maybe not.

How would you handle this case? The only thing I figured was:
from frozendict import frozendict, field
from dataclasses import dataclass

AD=frozendict(a=1)
@dataclass
class A:
    a: frozendict = field(default_factory=lambda:AD)

Which imho is cumbersome.
History
Date User Action Args
2021-07-24 06:45:59giannisetrecipients: + gianni, eric.smith, CCLDArjun
2021-07-24 06:45:59giannisetmessageid: <1627109159.36.0.509582449495.issue44674@roundup.psfhosted.org>
2021-07-24 06:45:59giannilinkissue44674 messages
2021-07-24 06:45:59giannicreate