enthought / enthought/traitsui

`Handler.init()` should return True/False

Open
#1,758 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

The declared API of `Handler.init()` is that it should return `True` if the handler was initialized successfully, or `False` if there was an issue and UI creation should be abandoned (in which case a `TraitError` is raised in `UI.prepare_ui()`).

However many examples, and a number of tests, have not returned anything (ie. so the return value is effectively `None`). The error-checking code has been testing for a return value of `False` rather than `if not handler.info(...)` so this code has been working fine.

As a result of this, there may be significant 3rd party code which returns `None` because it was following examples.

We should either:
- first warn, then raise an exception, when a non-bool value is returned from `Handler.init()`; or
- abandon the explicit return flag approach and simply expect that the `init` method simply raise an appropriate exception if there is an insurmountable issue with initializing the `Handler`.

See #1757 where the issue was first exposed and is partially addressed.

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.