traceback_with_variables icon indicating copy to clipboard operation
traceback_with_variables copied to clipboard

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

Open eddyg opened this issue 3 years ago • 1 comments

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?

eddyg avatar Oct 06 '22 13:10 eddyg

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.

andy-landy avatar Oct 06 '22 14:10 andy-landy