ID EN
Typing

Never

Python 3.11 🇮🇩 Bahasa Indonesia

Never dan NoReturn mewakili tipe terbawah, tipe yang tidak memiliki anggota.

Syntax

PYTHON
typing.Never

Contoh

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