Skip to content

Correct exceptions for nested types #508

@krey

Description

@krey
from traitlets import HasTraits, Union, Unicode, Bool

class Foo(HasTraits):
    bar = Union([Bool(), List(Unicode())])

Foo(bar=[1, 2, 3])
TraitError: The 'bar' trait of a Foo instance must be a boolean or a list, but a value of [1, 2, 3] <type 'list'> was specified.

If you're not looking at the code for Foo, the error message isn't gonna tell you what's wrong

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