Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created November 13, 2025 23:04
Show Gist options
  • Select an option

  • Save mypy-play/ebf1d2bc4712ea31d74a7540221bbfdd to your computer and use it in GitHub Desktop.

Select an option

Save mypy-play/ebf1d2bc4712ea31d74a7540221bbfdd to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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