Skip to content

Constant constraint not enforced in Union #1784

Description

@k2bd

Constant constraint is not enforced when initializing Union (came up in writing tests for #1298)

class TestClass(HasTraits):
    attribute = Union(None, Constant(123))

a = TestClass(attribute=456)  # No exception raised
a.attribute  # 456

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions