Tools/cases_generator/_typing_backports.py
raw| 1 | """Backports from newer versions of the typing module. |
| 2 | |
| 3 | We backport these features here so that Python can still build |
| 4 | while using an older Python version for PYTHON_FOR_REGEN. |
| 5 | """ |
| 6 | |
| 7 | from typing import NoReturn |
| 8 | |
| 9 | |
| 10 | def assert_never(obj: NoReturn) -> NoReturn: |
| 11 | """Statically assert that a line of code is unreachable. |
| 12 | |
| 13 | Backport of typing.assert_never (introduced in Python 3.11). |
| 14 | """ |
| 15 | raise AssertionError(f"Expected code to be unreachable, but got: {obj}") |