Skip to content

Add Void type #24557

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down