Skip to content

Allow three-argument converters (like validators/on_setattr) #709

@Drino

Description

@Drino

I'd like to move the discussion from converter decorator PR to this issue.

I think converters are semantically closer to on_setattr and validator than default. E.g. attr.ib(converter=...) allows you to pass a list of callables and pipes them automatically - exactly like attr.ib(validator=...) and attr.ib(on_setattr=...) and there is attr.converters module, like attr.setters and attr.validators.

If we allow passing half-initialized self to converter, why don't allow full-form converters, converter(self, attr, value) to make them the same as on_setattr, but for initialization?

To support one, two and three-argument converters there should be either inspect-magic (in py2 - getargspec, in py3 - signature) or mandatory Converter wrapper for two and three-argument converters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ThinkingNeeds more braining.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions