HasStrictTraits not respected in multiple inheritance
- Dominant language
- Python
- Stars
- 462
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
Consider the following:
```
class A(HasTraits):
pass
class B(HasStrictTraits):
pass
class C(A, B):
pass
class D(B, A):
pass
```
If we do
```
>>> c = C()
>>> c.a = 1
```
there is no error (which, given that we have inherited `HasStrictTraits`, we would expect to be raised).
On the other hand:
```
>>> d = D()
>>> d.a = 1
---------------------------------------------------------------------------
TraitError Traceback (most recent call last)
in ()
----> 1 d.a = 1
TraitError: Cannot set the undefined 'a' attribute of a 'D' object.
```
This behaves as expected.
The expected behaviour is that if a class inherits from `HasStrictTraits`, which is a subclass of `HasTraits`, then it should maintain the `HasStrictTraits` behaviour unless something is done to explicitly turn it off.
This issue is related to #401 and was first raised in https://github.com/enthought/pyface/issues/730 which has a more detailed analysis of the suspected root problem.
Contributor guide
No contributing guide indexed for this repository
Research direction
No source file or test is named. Start by running the C and D multiple-inheritance reproducer from the issue and tracing how HasTraits and HasStrictTraits determine undefined-attribute handling. Done means C rejects assignment to the undefined a attribute, while preserving the expected D behavior, with regression coverage for both inheritance orders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100