enthought / enthought/traits

Implicit value change from Enum items doesn't trigger change event

Open
#529 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Traits 5.1.2 and Python 3.6 (but I assume this is not python version-specific).

Here is a minimal example:
```python
from traits.api import Enum, HasTraits, List

class A(HasTraits):
x = Enum(values='things')
things = List

def _x_changed(self):
print('hi there')

if __name__ == '__main__':
a = A(things=[1, 2])

# `_x_changed` called since `x` initially gets default of 1
a.x = 2

# `x` gets implicitly changed to 1, but not until accessed
a.things.remove(2)

# a.x is 1, but no change event happened
print(a.x)
```

The expectation is that `_x_changed` gets called twice (or possibly three times if you include the fact that we did not explicitly provide a value for `x` at initialization and it got set to the first item from `things`).

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.