Typing and Generics

typing.Never

The bottom type describes values that cannot exist. Use it for unreachable branches and functions that never return normally; it is statically equivalent to NoReturn.

Formal Syntax & Structure

python syntaxpython
typing.Never

Return Value

Never

Typing construct or runtime result as described; static typing rules are not runtime validation.

Working Example

Example Snippetpython
from typing import Never
def fail() -> Never: raise ValueError('invalid')print(fail.__annotations__['return'] is Never)
Python Reference