aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Tools/cases_generator/_typing_backports.py
blob: c2aa50804cefe21b589c1d975d686a1179ec77ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""Backports from newer versions of the typing module.

We backport these features here so that Python can still build
while using an older Python version for PYTHON_FOR_REGEN.
"""

from typing import NoReturn


def assert_never(obj: NoReturn) -> NoReturn:
    """Statically assert that a line of code is unreachable.

    Backport of typing.assert_never (introduced in Python 3.11).
    """
    raise AssertionError(f"Expected code to be unreachable, but got: {obj}")