enthought / enthought/traits

Add IntRange and FloatRange trait type factories.

Open
#590 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

The current `Range` implementation is greatly complicated by the need to infer the value type, either statically from the provided low and high values, or dynamically when dynamic low or high values are first accessed. Not only that, but the late determination of the value type in the second case is a possible cause of bugs in the case of shared `Range` traits.

An upcoming reworking of the `Range` trait (see #594) will infer the value type at `Range` creation time and remove the late inference of the value type for dynamic ranges. To compensate for this, it will be possible to *specify* the value type at `Range` creation time using the `value_type` keyword.

To encourage (implicit) use of the `value_type` keyword, and explicit determination of the range value type, we suggest introducing `IntRange` and `FloatRange` trait type factories that correspond to `Range(..., value_type=Int)` and `Range(..., value_type=Float)` respectively.

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.