-
-
Notifications
You must be signed in to change notification settings - Fork 208
Closed
Milestone
Description
While the defaults values are validated against the type of their trait, they are not cross-validated against any @validate rules.
This may lead to conflicting behavior in HasTraits subclasses when they contain invalid defaults, as exemplified in #263, and copied here for clarity:
class A1(HasTraits):
virtue = Unicode('BAD')
@validate('virtue')
def _no_evil(self, proposal):
if proposal['value'] == 'BAD':
raise TraitError()
return proposal['value']
class A2(HasTraits):
virtue = Unicode('GOOD')
@validate('virtue')
def _no_evil(self, proposal):
if proposal['value'] == 'BAD':
raise TraitError()
>>> A1('virtue='BAD') ## Pass
>>> A2('virtue='BAD') ## Screams!
traitlets.traitlets.TraitErrorReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels