diff --git a/Lib/typing.py b/Lib/typing.py index 6224930c3b0275..ee13541487caa0 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -402,6 +402,24 @@ def stop() -> NoReturn: """ raise TypeError(f"{self} is not subscriptable") +@_SpecialForm +def Void(self, parameters): + """Special type indicating functions that do not return values. + Example:: + + from typing import Void, Any + + def nothing() -> Void: + pass + + nothing() #passes type checking + a: Any = nothing() #fails type checking + + This type is invalid in any context other than a function/method return + type annotation, e.g., ``List[Void]`` will fail in static type checkers. + """ + raise TypeError(f"{self} is not subscriptable") + @_SpecialForm def ClassVar(self, parameters): """Special type construct to mark class variables.