pyface
pyface copied to clipboard
Failure modes for missing Pygments are not good
With the Qt backend, if you don't have Pygments installed and try to use the CodeEditor
in TraitsUI you get a TextEditor
. With Pyface it's not quite so bad as you get an ImportError
which, if you have access to the source code, will lead you to the problem.
Furthermore when running from the command-line in the most obvious way you see no indication of what the problem is because the missing import message is sent out as debug-level and so is obscured.
It will be almost impossible for new users to work out what is going wrong.
I am leaning towards we should just fail loudly when the import of Pygments fails.
I am a bit confused about this issue. Is this related to the behaviour that TraitsUI editor factory always fall back to a text editor when any import fails? https://github.com/enthought/traitsui/issues/864
This may be where the pain comes from: https://github.com/enthought/traitsui/blob/fb8ea4a4e7df575a707e64cae8eb882a68ef995c/traitsui/editor_factory.py#L224-L227
This line is probably raising ImportError, which then get captured by the block above https://github.com/enthought/traitsui/blob/fb8ea4a4e7df575a707e64cae8eb882a68ef995c/traitsui/qt4/code_editor.py#L30