In [11]: class Foo(HasTraits):
....: pass
....:
In [12]: class Bar(Foo):
....: _ = Disallow
....:
In [13]: f = Foo()
In [14]: f.a = 12
In [15]: b = Bar()
In [16]: b.a = 12
---------------------------------------------------------------------------
TraitError Traceback (most recent call last)
/Users/chris/Development/git_repos/enaml/<ipython-input-16-a15ba401819f> in <module>()
----> 1 b.a = 12
TraitError: Cannot set the undefined 'a' attribute of a 'Bar' object.
But this is bad behavior with an instance defining behavior of the entire class and subclasses. It seems that adding an instance trait also gets added to the class traits dict. Not sure how deep down the rabbit hole fixing this would take us.
In [17]: class Foo(HasTraits):
....: pass
....:
In [18]: f = Foo()
In [19]: f.a = 12
In [20]: class Bar(Foo):
....: _ = Disallow
....:
In [21]: b = Bar()
In [22]: b.a = 12
This works as expected:
But this is bad behavior with an instance defining behavior of the entire class and subclasses. It seems that adding an instance trait also gets added to the class traits dict. Not sure how deep down the rabbit hole fixing this would take us.