Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created January 15, 2026 23:51
Show Gist options
  • Select an option

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

Select an option

Save mypy-play/38818ca2515ec447077ef432725386d7 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import final, assert_never, reveal_type
class Types:
@final
class A:
pass
@final
class B:
pass
def pprint(cls: type[Types.A | Types.B]) -> None:
match cls:
case Types.A:
print("A")
reveal_type(cls)
case Types.B:
print("B")
reveal_type(cls)
case _:
reveal_type(cls)
assert_never(cls)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment