Gianni Mariani <gia...@mariani.ws> added the comment:

@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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44674>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to