[PATCH B4] Show name of module that causes import error
Nicolas Schier <[email protected]> Thu, 23 Jul 2026 11:43:59 +0200
| Newsgroups | org.kernel.linux.tools |
|---|---|
| Message-ID | <20260723-show-name-of-module-that-causes-import-error-v1-1-d3c0d71834e2@fritz.com> |
Update the error message for import errors to show the name of the Python
module or library that is missing effectively.
Running 'b4 review tui' on a system that has the Python textual library
installed but misses pygit2, results in
The TUI requires the textual library.
Install it with: pip install b4[tui]
Showing the correct name contained in the ImportError instead of
'textual' may help in such cases.
Signed-off-by: Nicolas Schier <[email protected]>
---
src/b4/bugs/__init__.py | 4 ++--
src/b4/review/_review.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/b4/bugs/__init__.py b/src/b4/bugs/__init__.py
index 1cd2db42756d..24f0f6364e35 100644
--- a/src/b4/bugs/__init__.py
+++ b/src/b4/bugs/__init__.py
@@ -201,8 +201,8 @@ def cmd_tui(cmdargs: argparse.Namespace) -> None:
"""Launch the bug management TUI."""
try:
from b4.bugs._tui import BugListApp
- except ImportError:
- logger.critical('The TUI requires the textual library.')
+ except ImportError as e:
+ logger.critical(f'The TUI requires the {e.name} library.')
logger.critical('Install it with: pip install b4[tui]')
sys.exit(1)
diff --git a/src/b4/review/_review.py b/src/b4/review/_review.py
index a3d82acc186c..a14d7afbb05c 100644
--- a/src/b4/review/_review.py
+++ b/src/b4/review/_review.py
@@ -2444,8 +2444,8 @@ def update_series_tracking(
def cmd_tui(cmdargs: argparse.Namespace) -> None:
try:
from b4.review_tui._entry import run_tracking_tui
- except ImportError:
- logger.critical('The TUI requires the textual library.')
+ except ImportError as e:
+ logger.critical(f'The TUI requires the {e.name} library.')
logger.critical('Install it with: pip install b4[tui]')
sys.exit(1)
---
base-commit: 0e65f947e4f98a3c48a47f280a86dd23845259b0
change-id: 20260611-show-name-of-module-that-causes-import-error-2c84ea5f63bf
Best regards,
--
Nicolas Schier