-
-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Description
- cattrs version: 1.3.0
- Python version: Python 3.9.1
- Operating System: macOS 11.2.1
Description
Python 3.9 deprecated typing.<containers> in favor of using collections.abc.<containers>. Using collections.abc. containers does not work as expected, though.
What I Did
from collections import abc
import typing
from attr import define
from cattr import GenConverter
@define
class A:
a: int
@define
class B:
b: typing.MutableSequence[A]
@define
class C:
c: abc.MutableSequence[A]
converter = GenConverter()
if __name__ == "__main__":
a = A(1)
b = B([a])
print(converter.unstructure(b))
c = C([a])
print(converter.unstructure(c))The actual output is:
{'b': [{'a': 1}]}
{'c': [A(a=1)]}
What I expected:
{'b': [{'a': 1}]}
{'c': [{'a': 1}]}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels