You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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.
The
NoReturn
type indicates the function either never terminates or always throws an exception:From PEP-484:
By having it set to
NoReturn
, all the code after the call toglobal_print_exc()
is "dimmed" in type-aware IDEs like VS Code. (For example,NoReturn
makes sense for annotatingsys.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 beNone
, or am I missing something?The text was updated successfully, but these errors were encountered: