Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print InspectError traceback in stubgen walk_packages when verbose is specified #18224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gareth-cross
Copy link

This change modifies walk_packages such that the full ImporError traceback is printed when a module cannot be imported. The goal is to provide the user with more context to debug the error.

I implemented this change by mirroring existing behavior in find_module_paths_using_imports:

mypy/mypy/stubgen.py

Lines 1522 to 1529 in 9405bfd

try:
result = find_module_path_and_all_py3(inspect, mod, verbose)
except CantImport as e:
tb = traceback.format_exc()
if verbose:
sys.stdout.write(tb)
if not quiet:
report_missing(mod, e.message, tb)

Copy link
Contributor

github-actions bot commented Dec 1, 2024

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant