Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created July 22, 2024 00:59
Show Gist options
  • Save mypy-play/2f45500a477c0ef501d9928e24b0896a to your computer and use it in GitHub Desktop.
Save mypy-play/2f45500a477c0ef501d9928e24b0896a to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import TypeVar
T1 = TypeVar("T1")
T2 = TypeVar("T2")
def f(t1: T1, t2: T2) -> T1 | T2:
return t1
a: int = f(1, None) or 1
def f1(t1: T1, t2: T1) -> T1:
return t1
b: int = f1(1, None) or 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment