enthought / enthought/traits

Trait(3, Range(2, "high")) has bad default value parameters

Open
#592 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

With the most recent release (5.2.0), and on current Traits master:
```
>>> from traits.api import Range, Trait, HasTraits
>>> range_trait = Trait(3, Range(2, "high"))
>>> range_trait

>>> range_trait.default_value()
(8, 3)
>>> range_trait.default_value_for(HasTraits(), "foo")
Traceback (most recent call last):
File "", line 1, in
TypeError: 'int' object is not callable
```

The `8` in the `default_value()` output is the default value type, and is code for a callable default, but the default value is then `3`, which isn't callable.

Note that there's nothing particularly special about the `Range` here; any trait type that uses `CALLABLE_DEFAULT_VALUE` for its default value type would have the same problem.

This looks like a bug somewhere in the `_TraitMaker` machinery.

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.