enthought / enthought/traitsui
Remove duplicate `eval_when` methods
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
A number of objects have an `eval_when` method that are effectively the same (with minor differences):
- this evaluates an expression to a boolean within an execution context (either menu or UI)
- sets a trait on an object to the result (or not, if it errors)
- catches errors and reports them (in _most_ cases)
This is similar, but subtly different from the `UI.eval_when` method in that:
- it does `setattr` rather than returning the result of the evaluation
- the context used may be something other than the UI context (in particular, it may be the editor's `_menu_context`)
These methods can probably be turned into a utility function that gets passed the expression, the context, the object and the trait and has just one standard reporting mechanism.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.