fromtypingimportTypeVarT1=TypeVar("T1")
T2=TypeVar("T2")
deffoo(a: T1, b: T2) ->T1|T2:
returnainvalid=1if1elsefoo(1, "s") # error: Argument 2 to "foo" has incompatible type "str"; expected "int"valid=foo(1, "s") if1else1https://mypy-play.net/?mypy=latest&python=3.10&gist=791645f9a348afc114cf3769ed85c30a
https://mypy-play.net/?mypy=latest&python=3.10&gist=791645f9a348afc114cf3769ed85c30a