Created
December 5, 2025 22:54
-
-
Save mypy-play/3dc5c105d72ba997443f1c4f58a179a0 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
| import re | |
| import types | |
| def fun(val: str | re.Pattern | None): | |
| match val: | |
| case str(): | |
| print('string') | |
| case re.Pattern(): | |
| print('pattern') | |
| case types.NoneType(): | |
| print('None') | |
| fun('123') | |
| fun(re.compile('456')) | |
| fun(None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment