8000 Graceful exit on KeyboardInterrupt by cdce8p · Pull Request #10725 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Graceful exit on KeyboardInterrupt #10725

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

Merged
merged 4 commits into from
Nov 19, 2021

Conversation

cdce8p
Copy link
Collaborator
@cdce8p cdce8p commented Jun 27, 2021

Description

Catch KeyboardInterrupt to allow graceful exit instead of printing the traceback.

Screen Shot 2021-08-02 at 09 26 50

Test Plan

Run mypy and trigger a KeyboardInterrupt. No traceback should be shown.

@cdce8p cdce8p force-pushed the keyboard-interrupt branch 4 times, most recently from 46eb998 to 0d64bd8 Compare August 2, 2021 09:59
@cdce8p cdce8p force-pushed the keyboard-interrupt branch from 0d64bd8 to 466332c Compare August 5, 2021 11:58
@JukkaL
Copy link
Collaborator
JukkaL commented Sep 21, 2021

This seems like a nice usability win, but the traceback can be useful for debugging in case there's an endless loop (which is quite rare, but it might still happen). Is there a way to display the traceback when it's actually useful? Maybe display the traceback when using mypy -v or mypy --show-traceback.

@cdce8p
Copy link
Collaborator Author
cdce8p commented Sep 22, 2021

This seems like a nice usability win, but the traceback can be useful for debugging in case there's an endless loop (which is quite rare, but it might still happen). Is there a way to display the traceback when it's actually useful? Maybe display the traceback when using mypy -v or mypy --show-traceback.

I've added options parsing to the KeyboardInterrupt handler. At the moment the traceback will only be printed on --show-traceback but I can easily extend it to -v as well (if you want me to).

@cdce8p cdce8p force-pushed the keyboard-interrupt branch from 7b25f8c to 6917deb Compare October 13, 2021 21:47
@cdce8p cdce8p force-pushed the keyboard-interrupt branch from 6917deb to 3d6ed8e Compare October 26, 2021 10:32
@cdce8p cdce8p force-pushed the keyboard-interrupt branch from 3d6ed8e to 90efdd7 Compare November 7, 2021 12:33
@cdce8p cdce8p force-pushed the keyboard-interrupt branch from 90efdd7 to ed4aab7 Compare November 11, 2021 18:55
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Copy link
Collaborator
@97littleleaf11 97littleleaf11 left a comment

Choose a reason for hiding this comment

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

lgtm!

@97littleleaf11 97littleleaf11 merged commit d7c4e69 into python:master Nov 19, 2021
@cdce8p cdce8p deleted the keyboard-interrupt branch November 19, 2021 03:02
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
Catch KeyboardInterrupt to allow graceful exit instead of printing the traceback.

Adds options parsing to the KeyboardInterrupt handler. At the moment
the traceback will only be printed on --show-traceback but can easily 
extend it to -v as well.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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.

4 participants
0