Extended trait listeners not called on intermediate list items changes
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Given the following code:
```
from traits.api import HasTraits, List, Instance, Int
class Child(HasTraits):
value = Int
class Parent(HasTraits):
children = List(Instance(Child))
p = Parent()
def printer(object, name, old, new):
print('Printing', object, name, old, new)
def notifier():
print('Changed')
p.on_trait_change(printer, 'children.value')
p.on_trait_change(notifier, 'children.value')
p.children = [Child()]
p.children.append(Child(value=10))
```
Notice that both listeners fire on change to the entire list, but only the one with no arguments fires on modification of the list. The documentation says that it _should_ fire:
> In the case of List or Dict traits, ... The handler routine is also invoked when items are added or removed from a list or dictionary, because this is treated as an implied change to the item’s trait being monitored.
This is presumably a long-standing bug, as this test comments and has a FIXME for this issue https://github.com/enthought/traits/blob/master/traits/tests/test_extended_trait_change.py#L467
Given the structure of the test here https://github.com/enthought/traits/blob/master/traits/tests/test_extended_trait_change.py#L462-L464
the expectation is that it should get a standard `TraitListEvent` for the change.
Feel free to delete if this is a duplicate.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.