Skip to content

Commit

Permalink
Improve stubtest error message (#15398)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Jun 8, 2023
1 parent e253e76 commit 27593bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ def test_module(module_name: str) -> Iterator[Error]:
except KeyboardInterrupt:
raise
except BaseException as e:
yield Error([module_name], f"failed to import, {type(e).__name__}: {e}", stub, MISSING)
note = ""
if isinstance(e, ModuleNotFoundError):
note = " Maybe install the runtime package or alter PYTHONPATH?"
yield Error(
[module_name], f"failed to import.{note} {type(e).__name__}: {e}", stub, MISSING
)
return

with warnings.catch_warnings():
Expand Down

0 comments on commit 27593bc

Please sign in to comment.