I'd personally be able to get rid of a lot of boilerplate (either at call sites or as __init__ methods) from my classes if attrs allowed me to supply a conversion callable with my attr.ibs.
e.g.
from pyrsistent import pmap
@attr.s
class Foo(object):
mapping = attr.ib(coerce=pmap)
The coerce argument (naming to be bikeshedded) would be called with the value passed in after validation, and the return value would be used as the actual attribute value.
Would such a feature be accepted as a patch?
I'd personally be able to get rid of a lot of boilerplate (either at call sites or as
__init__methods) from my classes if attrs allowed me to supply a conversion callable with myattr.ibs.e.g.
The
coerceargument (naming to be bikeshedded) would be called with the value passed in after validation, and the return value would be used as the actual attribute value.Would such a feature be accepted as a patch?