Bad behavior of inherited traits with _ = Disallow
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
This works as expected:
```
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/ in ()
----> 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
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.