Hi, first of all I want to thank you for adding the support for structuring and destructuring of Final attributes in cattrs 23. I've been using it throughout my codebase ever since and it's proven very useful. Unfortunately, I might have run into a bug of this new feature. In particular, cattrs fails when attempting to structure Final sequences.
Example
The following minimal example
from typing import Final
import attr
from cattrs.preconf.json import JsonConverter
@attr.s(init=True)
class Foo:
foo: Final[list[float]] = attr.ib()
converter = JsonConverter()
converter.loads('{ "foo": [0.12] }', Foo)
The same issue happens also if a tuple or a generic Sequence are used instead of a list. Moreover, if the Final from the definition of Foo is removed, then the json string is structured correctly and without errors.
Versions
Description
Hi, first of all I want to thank you for adding the support for structuring and destructuring of
Final
attributes incattrs
23. I've been using it throughout my codebase ever since and it's proven very useful. Unfortunately, I might have run into a bug of this new feature. In particular,cattrs
fails when attempting to structureFinal
sequences.Example
The following minimal example
results in the error
The same issue happens also if a
tuple
or a genericSequence
are used instead of alist
. Moreover, if theFinal
from the definition ofFoo
is removed, then the json string is structured correctly and without errors.