Closed
Description
- cattrs version: 23.2.0
- Python version: 3.10
- Operating System: macos 13.5.1
Description
>>> cattrs.structure({"a": 1, "b": 2}, List)
['a', 'b']
I would expect it to complain that the dictionary it's trying to structure is not a list. While I understand where this logic may be coming from (a dictionary is an Iterable
, so it's fine to convert it to a list), it is losing information this way, which doesn't seem like a good choice for the default behavior. Also the docs don't list Iterable
as something that gets structured to a list, and dictionaries are not Sequence
.
Is it intentional, and if yes, is there a way to make it more strict, in a way that's composable (that is, so I don't have to define a custom structuring function for list of every type I have)?
Metadata
Metadata
Assignees
Labels
No labels