Created
January 15, 2026 23:51
-
-
Save mypy-play/38818ca2515ec447077ef432725386d7 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 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