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

Is "NoReturn" the proper annotation for global_print_exc()? #25

Open
eddyg opened this issue Oct 6, 2022 · 1 comment
Open

Is "NoReturn" the proper annotation for global_print_exc()? #25

eddyg opened this issue Oct 6, 2022 · 1 comment

Comments

@eddyg
Copy link

eddyg commented Oct 6, 2022

The NoReturn type indicates the function either never terminates or always throws an exception:

From PEP-484:

The typing module provides a special type NoReturn to annotate functions that never return normally. For example, a function that unconditionally raises an exception..

By having it set to NoReturn, all the code after the call to global_print_exc() is "dimmed" in type-aware IDEs like VS Code. (For example, NoReturn makes sense for annotating sys.exit() with the visual indication that none of the code after it will ever execute.)

Since the function is simply setting sys.excepthook, shouldn't the return type simply be None, or am I missing something?

@andy-landy
Copy link
Owner

Thanks for pointing that! My bad, at the time of implementing it I sincerely thought that "-> None" stands for "return None" while "-> NoReturn" stands for mere "return" ;) Let me fix that in the next version.

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

No branches or pull requests

2 participants