enthought / enthought/traits

Trait inheritance fails for callable defaults

Open
#601 4 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

It's supposed to be possible to override a trait's default value in a subclass without redeclaring that Trait. However, for traits whose default is computed via a function call (i.e., their `default_value_type` is `CALLABLE_DEFAULT_VALUE`), this doesn't work correctly.

Example:

```
>>> from traits.api import *
>>> class Employee(HasTraits):
... salary = Range(value=1, low=1, high="high")
... high = Int(10)
...
>>> class Manager(Employee):
... salary = 5
...
>>> manager = Manager()
>>> manager.salary # expected 5
1
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.