traits
traits copied to clipboard
Observable typed attributes for Python classes
I have observed some weird behavior when calling `hasattr` with a nonexistent attribute. Assume the following as a minimal example: ```python class AClass(ta.HasTraits): pass def observer(val): print(f"observed: {val}") inst =...
I'm seeing a test failure with the latest Traits and TraitsUI from PyPI, on Python 3.11. (I haven't tested with other Python versions, but it likely affects those, too.) Steps...
Using a `Property` depending on a nested trait in a `ReadOnly`, the `Property` doesn't fire change events, when the nested trait changed. However, an `observe` on this nested trait fires....
Recent changes in Envisage added GitHub Actions workflows for automatically updating the gh-pages branch: - on every commit to the main branch (so every PR merge for PRs against main),...
For testing purposes, it's often convenient to make temporary changes to the state of the global `ETSConfig` object and then undo those changes in the test cleanup. This generally involves...
In the sample below exceptions that are raised through `observe` cannot be caught in unit tests. It's expected behavior, but it may be surprising to some. ``` import unittest from...
An issue we are currently seeing trying to remove `Trait(...)` and `Either(...)` from Chaco: when you have `Union(..., FooTrait, ...)` where `FooTrait` is a mapped trait, union does not carry...
Closes #1298 This PR: - Creates the `Optional` trait type as a shorthand for `Union(None, ...)` - Changes exception messages in `Union` to refer to subclass names, e.g. `Optional` (let...
`Constant` constraint is not enforced when initializing `Union` (came up in writing tests for #1298) ```python class TestClass(HasTraits): attribute = Union(None, Constant(123)) a = TestClass(attribute=456) # No exception raised a.attribute...
The `observe` event classes `TraitChangeEvent`, `DictChangeEvent`, `ListChangeEvent` and `SetChangeEvent` should be exposed in `traits.observation.api`, at least partly so that they can be used in type annotations. I'm not sure why...