Skip to content

Commit 6fb1423

Browse files
committed
Display exception string when loading a plugin failed
This helps with seeing what the issue is (e.g. with django-stubs [1]). It might be even better to have a traceback there already, no? 1: typeddjango/django-stubs#160
1 parent 125ef0d commit 6fb1423

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mypy/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ def plugin_error(message: str) -> None:
381381

382382
try:
383383
module = importlib.import_module(module_name)
384-
except Exception:
385-
plugin_error("Error importing plugin '{}'".format(plugin_path))
384+
except Exception as exc:
385+
plugin_error("Error importing plugin '{}': {}".format(plugin_path, exc))
386386
finally:
387387
if plugin_dir is not None:
388388
assert sys.path[0] == plugin_dir

test-data/unit/check-custom-plugin.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ tmp/mypy.ini:2: error: Can't find plugin 'tmp/missing.py'
7070
[[mypy]
7171
plugins=missing
7272
[out]
73-
tmp/mypy.ini:2: error: Error importing plugin 'missing'
73+
tmp/mypy.ini:2: error: Error importing plugin 'missing': No module named 'missing'
7474

7575
[case testMultipleSectionsDefinePlugin]
7676
# flags: --config-file tmp/mypy.ini

0 commit comments

Comments
 (0)