[New-bugs-announce] [issue44674] dataclasses should allow frozendict default value

Gianni Mariani report at bugs.python.org
Mon Jul 19 10:06:32 EDT 2021


New submission from Gianni Mariani <gianni at mariani.ws>:

Using a frozendict as a default value should not cause an error in dataclasses. The check for mutability is:

   isinstance(f.default, (list, dict, set))

It appears frozendict has been changed to have a dict base class and it now raises an exception.

There should be a way to indicate object mutability as the purpose of the isinstance(f.default, (list, dict, set)) check is for mutable default values.

Using default_factory to work around this issue is cumbersome.

----------
components: Library (Lib)
messages: 397799
nosy: gianni
priority: normal
severity: normal
status: open
title: dataclasses should allow frozendict default value
type: compile error
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44674>
_______________________________________


More information about the New-bugs-announce mailing list