Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Print InspectError traceback in stubgenwalk_packages when verbose is specified#18224

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@gareth-cross
Copy link
Contributor

This change modifieswalk_packages such that the fullImporError 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 infind_module_paths_using_imports:

mypy/mypy/stubgen.py

Lines 1522 to 1529 in9405bfd

try:
result=find_module_path_and_all_py3(inspect,mod,verbose)
exceptCantImportase:
tb=traceback.format_exc()
ifverbose:
sys.stdout.write(tb)
ifnotquiet:
report_missing(mod,e.message,tb)

@github-actions

This comment has been minimized.

Copy link
Collaborator

@hamdanalhamdanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks. Could you print the traceback tostderr instead? You might also changefind_module_paths_using_imports to print tostderr as well.

@gareth-cross
Copy link
ContributorAuthor

Thanks. Could you print the traceback tostderr instead? You might also changefind_module_paths_using_imports to print tostderr as well.

Done for both.

@brianschubert
Copy link
Collaborator

(For future reference: try to avoid force pushing. It makes it hard to review changes. We squash merge anyway, so extra commits in the PR history doesn’t matter)

@gareth-cross
Copy link
ContributorAuthor

(For future reference: try to avoid force pushing. It makes it hard to review changes. We squash merge anyway, so extra commits in the PR history doesn’t matter)

Apologies - good call.

@github-actions
Copy link
Contributor

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

Copy link
Collaborator

@hamdanalhamdanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks.

gareth-cross reacted with thumbs up emoji
@hauntsaninjahauntsaninja merged commitceaf48d intopython:masterDec 21, 2024
20 checks passed
@gareth-crossgareth-cross deleted the verbose-import-error-print branchDecember 21, 2024 23:00
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@hauntsaninjahauntsaninjahauntsaninja approved these changes

+1 more reviewer

@hamdanalhamdanalhamdanal approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@gareth-cross@brianschubert@hauntsaninja@hamdanal

[8]ページ先頭

©2009-2025 Movatter.jp