Skip to content

Explicitly specify the field which does not require structuring #50

@dmfigol

Description

@dmfigol
  • cattrs version: 0.9.0
  • Python version: 3.6.6
  • Operating System: macOS

Description

I use cattrs + attrs (w/ type annotations and auto_attribs=True) + marshmallow. Marshmallow does data normalization and then the data is passed through cattr converter to be deserealized into Python objects. When the data is normalized, I already get proper "simple" types, like datetime, so I don't need another conversion.
I would like to indicate to cattrs that it should not do conversion, ideally on per field basis, not on per type basis.
Currently, I specify lambda x, _: x converter per type.

I have similar problem when I specify Union of different types. Those can be float, str, datetime and I don't need to convert them.
May be it is already possible, but I haven't found this in the docs.

typing.Any is not desirable, because then I lose my types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions