Skip to content

Configurable validates too often #390

@jasongrout

Description

@jasongrout

Consider this:

from traitlets.config import Configurable
class A(Configurable):
    x = Int(1)
    
    @validate('x')
    def f(self, proposal):
        print('validate x')
        return proposal.value
A(x=5)

prints:

validate x
validate x

while this:

from traitlets import HasTraits
class A(HasTraits):
    x = Int(1)

    @validate('x')
    def f(self, proposal):
        print('validate x')
        return proposal.value
A(x=5)

only validates x once:

validate x

For some reason, Configurable is validating x twice, but HasTraits is only validating once.

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