Skip to content

Commit 27593bc

Browse files
authored
Improve stubtest error message (#15398)
1 parent e253e76 commit 27593bc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mypy/stubtest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ def test_module(module_name: str) -> Iterator[Error]:
209209
except KeyboardInterrupt:
210210
raise
211211
except BaseException as e:
212-
yield Error([module_name], f"failed to import, {type(e).__name__}: {e}", stub, MISSING)
212+
note = ""
213+
if isinstance(e, ModuleNotFoundError):
214+
note = " Maybe install the runtime package or alter PYTHONPATH?"
215+
yield Error(
216+
[module_name], f"failed to import.{note} {type(e).__name__}: {e}", stub, MISSING
217+
)
213218
return
214219

215220
with warnings.catch_warnings():

0 commit comments

Comments
 (0)