Created
November 13, 2025 23:04
-
-
Save mypy-play/ebf1d2bc4712ea31d74a7540221bbfdd to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Never | |
| def very_sound_function() -> float: | |
| y: list[Never] = [] | |
| return next(iter(y)).startswith("xyz") # type checker approved! | |
| # ^^^^^^^^^^^^^ this may have been a good place to error | |
| # if we really believed Never was uninhabited. | |
| def make_never() -> Never: | |
| while True: | |
| pass | |
| x: Never = make_never() # yep, totally uninhabited. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment