ID EN
Typing

Never

Python 3.11

The bottom type, a type that has no members.

Syntax

PYTHON
typing.Never

Examples

Example 1
PYTHON
from typing import Never

def never_call_me(arg: Never) -> None:
    pass

def int_or_str(arg: int | str) -> None:
    never_call_me(arg)   type checker error
    match arg:
        case int():
            print("It's an int")
        case str():
            print("It's a str")
        case _:
            never_call_me(arg)   OK, arg is of type Never

See Also

NoReturn