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

fix: don't set excepthook unless pretty_exceptions_enable #1030

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

charmoniumQ
Copy link

Previously, pretty_exceptions_enable means "set sys.excepthook to the default exception handler". This commit changes the interpretation to "simply don't change sys.excepthook at all". If it was the default handler before, it will remain the default handler. If it was a customized excepthook before, it will remain a customized excepthook.

This interpretation gives more control to users when pretty_exceptions_enable is False, while maintaining the same out-of-the-box experience for users who leave it at its default (True).

Since sys.excepthook is for uncaught exceptions, it will be read directly by humans, I don't expect this change to break any users of Typer. Most users would leave pretty_exceptions_enable to the default (True), and that behavior did not change at all in this commit.

charmoniumQ and others added 2 commits October 26, 2024 12:47
Previously, pretty_exceptions_enable means "set sys.excepthook to the default exception handler". This commit changes the interpretation to "simply don't change sys.excepthook at all". If it was the default handler before, it will remain the default handler. If it was a customized excepthook before, it will remain a customized excepthook.

This interpretation gives more control to users when pretty_exceptions_enable is False, while maintaining the same out-of-the-box experience for users who leave it at its default (True).

Since sys.excepthook is for uncaught exceptions, it will be read directly by humans, I don't expect this change to break any users of Typer. Most users would leave pretty_exceptions_enable to the default (True), and that behavior did not change at all in this commit.
@svlandeg
Copy link
Member

Hi @charmoniumQ, thanks for the contribution! Currently this PR is failing the CI - there appear to be some failing tests. Could you look into those? It would be much more straightforward to review this PR and its proposed changes once all unit tests are green. Thanks! 🙏

@svlandeg svlandeg added the feature New feature, enhancement or request label Oct 29, 2024
@svlandeg svlandeg marked this pull request as draft October 29, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request waiting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants