traits
traits copied to clipboard
Observable typed attributes for Python classes
Loving traits! I have created a wrapper class that does some pretty printing among other things. I'm getting the following error when of my classes attributes is a List(): ```...
Running ``` from traits.api import HasTraits, Int, Range class Foo(HasTraits): bar = Int(10) baz = Range(low=0, high=10) def _baz_default(self): print('_baz_default') return 5 if __name__ == '__main__': foo = Foo() print(foo.baz)...
https://github.com/enthought/traits/blob/34fa3ca9f7b0c364531b688cd7d7b3261be59b1a/traits/etsconfig/etsconfig.py#L263-L291
In the example below, attaching a listener to a `Property(List)` produces an obscure, hard-to-diagnose error: ```python from traits.api import HasStrictTraits, Instance, List, Property, Str class Person(HasStrictTraits): name = Str() class...
There's a pattern that's turned up a good many times in various different projects over the years, where it may make sense to document the issues and possible solutions. It...
I've created a series of PRs aimed at bypassing the default_value_type inference code for `TraitType` subclasses. See #1531, #1532, #1536. Code link: https://github.com/enthought/traits/blob/9f934334668c6c0bf1e2866d6a81417275bbc255/traits/trait_type.py#L34-L52 Rationale: - making Traits less DWIMmy; in...
I was rather surprised to discover that it's possible to at least install Traits on PyPy, that basic operations work, and that at least some of the test suite passes....
`remove_trait()` is supposed to be used for traits that were added via `add_trait()`, however this is neither specified in the docstring https://github.com/enthought/traits/blob/eb0027f3d6a57968104949e5a5fc5d7db9d4a577/traits/has_traits.py#L2842-L2854 or elsewhere in the documentation, nor enforced in...
This arose from a discussion in internal chat. Given a cached property `y` depending on `x`, you might expect that whenever `x` and `y` are observed, they should be consistent....
PR #1388 fixed validation for dynamic `Enum`s inside a container (e.g., a `List` or `Tuple`). An unanticipated side-effect of that change is that dynamic defaults for dynamic `Enum`s are also...