Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created December 5, 2025 22:54
Show Gist options
  • Select an option

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

Select an option

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