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

Handle CTRL+C by showing a better message #3511

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions codespell_lib/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
from ._codespell import _script_main

if __name__ == "__main__":
try:
sys.exit(_script_main())
except KeyboardInterrupt:
pass
sys.exit(_script_main())

Check warning on line 6 in codespell_lib/__main__.py

View check run for this annotation

Codecov / codecov/patch

codespell_lib/__main__.py#L6

Added line #L6 was not covered by tests
7 changes: 6 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,12 @@

def _script_main() -> int:
"""Wrap to main() for setuptools."""
return main(*sys.argv[1:])
try:
return main(*sys.argv[1:])
except KeyboardInterrupt:

Check warning on line 1104 in codespell_lib/_codespell.py

View check run for this annotation

Codecov / codecov/patch

codespell_lib/_codespell.py#L1104

Added line #L1104 was not covered by tests
# User has typed CTRL+C
sys.stdout.write("\n")
return 130

Check warning on line 1107 in codespell_lib/_codespell.py

View check run for this annotation

Codecov / codecov/patch

codespell_lib/_codespell.py#L1106-L1107

Added lines #L1106 - L1107 were not covered by tests


def _usage_error(parser: argparse.ArgumentParser, message: str) -> int:
Expand Down
Loading