from dataclasses import dataclass
import msgspec
@dataclass(frozen=True, slots=True)
class Foo:
foo_value: int = 0
foo = msgspec.convert({}, Foo) # fails
The traceback:
Traceback (most recent call last):
File "~/foo.py", line 9, in <module>
foo = msgspec.convert({}, Foo)
^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 4, in __setattr__
dataclasses.FrozenInstanceError: cannot assign to field 'foo_value'
If the value for foo_value is provided in the initial dictionary, there is no error. Also, the error is only raised if slots=True is present.
Description
The following will fail:
The traceback:
If the value for
foo_value
is provided in the initial dictionary, there is no error. Also, the error is only raised ifslots=True
is present.