Open kitchoi opened 3 years ago
For the record, I prefer getting an ImportError on pygments when one attempts to import pyface.python_shell
or pyface.python_editor
directly when the dependency is missing. In other words, I oppose to the proposed change.
Unlike the api module, these modules have very narrow and specific scope for the feature they provide. If one needs Python Shell or Python editor in their GUI, then they need pygments (unless the editors have some fallback mechanism to show code without styled formatting, but that is a whole separate issue). Getting an import error early for missing pygments would make debugging easier for both users and maintainers.
Copied from this comment and this comment:
from .toolkit import toolkit_object
try: PythonEditor = toolkit_object("python_editor:PythonEditor") except ImportError as _exception:
Excuse pygments dependency (for Qt), otherwise re-raise