Closed
Description
I was surprised by the following:
from attr import assoc, attr, attributes
from attr.validators import instance_of
@attributes
class Foo(object):
a = attr(validator=instance_of(int))
foo = Foo(1)
try:
foo = Foo("1")
except TypeError:
pass
else:
raise ValueError()
try:
foo2 = assoc(foo, a="1")
except TypeError:
pass
else:
raise ValueError("Could set Foo.a to a string value")
I would expect new instances set through assoc
to go through validators. Is this a bug, or is it expected ?
Metadata
Metadata
Assignees
Labels
No labels