enthought / enthought/traits

`Constant` constraint not enforced in `Union`

Open
#1,784 1 comment 0 reactions 0 assignees View on GitHub
component: core type: bug
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

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

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

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.