Comments (5)
I ran into the same issue today, did you manage to work around this issue?
from traits.
Related to this (not raising an error, but surprising):
from traits.api import HasTraits, Dict, Str, List, Int
class TestList(HasTraits):
x = List(List(Int))
class TestDict(HasTraits):
x = Dict(Str, List)
class TestDict2(HasTraits):
x = Dict(Str, Dict(Str, Int))
def listener(obj, name, old, new):
print obj, name, old, new.added
t1 = TestList(x=[[1, 2, 3]])
t1.on_trait_change(listener, name='x_items')
t1.x[0].append(4) # listener fires with data from sub-list as if it were main list
t2 = TestDict(x={'a': [1, 2, 3]})
t2.on_trait_change(listener, name='x_items')
t2.x['a'].append(4) # exception, as noted above
t3 = TestDict2(x={'a': {'b': 1}})
t3.on_trait_change(listener, name='x_items')
t3.x['a']['c'] = 2 # listener fires with data from sub-dict as if it were main dict
The root issue is with recursive calls to List.validate
or Dict.validate
when building the TraitListObject
or TraitDictObject
instances. This is non-trivial to fix: it's not even clear what the "right" behaviour should be.
from traits.
I ran into the same issue (in the Dict(Str, List)
case). To work around it, @Bouke , I simplified my declaration to Dict()
. @rkern also suggested offline to use Dict(Str, Instance(list)) if you need the typechecking.
from traits.
This is essentially the same issue as #281. We should close one or the other.
from traits.
Closed #281 as a duplicate of this issue; there's some useful discussion in comments on that issue.
from traits.
Related Issues (20)
- Remove 'except Exception' guard from `TraitType.clone`
- Document that handlers (e.g., `TraitType` subclasses) should be stateless
- Envisage and Apptools cron jobs failing to build traits HOT 2
- `Union` doesn't handle mapped traits
- Explain why exceptions don't bubble up in observers
- `=traits-6.1.1` fails tests with `Documenter.add_content() got an unexpected keyword argument 'no_docstring'` HOT 2
- Unexpected failure mode for `dispatch="ui"` when there is no UI HOT 6
- 6.4.1 not compatible with python-envisage 6.1.0 HOT 3
- Provide methods to save and restore state of the global ETSConfig HOT 1
- [BUG] `Property` not notified of changes in `ReadOnly` trait.
- `sre_parse` and `sre_constants` modules are deprecated HOT 2
- CI failures due to TraitsUI qt4 imports
- Automatically update gh-pages documentation on commits and releases
- test_configure_traits.py failed due to unexpected number of warnings in test_edit_not_given
- AttributeErrors are silently caught by trait_get() HOT 5
- Tests fail with latest Traits and TraitsUI from PyPI HOT 1
- Make a 6.4.2 release HOT 1
- Calling `hasattr`/`getattr` creates trait if missing. HOT 2
- Sphinx 7.2 breaks trait documenter tests HOT 4
- Wouldn't it be possible to split getting and setting prefix traits?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traits.