Open jeongukjae opened 2 months ago
Tried to figure out, but couldn't.
Test case:
[case testVariadicGenericFunction]
# flags: --python-version 3.10
from typing import Union, Type, Tuple, TypeVar
T = TypeVar("T")
def some_types(types_: Tuple[Type[T], ...]) -> T: ...
def int_str_float_fn(a: int | str | float) -> None: ...
a = some_types((int, str, float)) # This should be int | str | float
int_str_float_fn(a) # should't be an error
[builtins fixtures/tuple.pyi]
Looks like mypy joins int, str, float to object rather than using union in here: https://github.com/python/mypy/blob/fe15ee69b9225f808f8ed735671b73c31ae1bed8/mypy/solve.py#L277-L282
Bug Report
It looks like mypy cannot detect some types like following type.
To Reproduce
Playground: https://mypy-play.net/?mypy=latest&python=3.12&gist=f83671bbbc02711ac90962ae786b418b
I got an error like
Expected Behavior
No error here.
I think VSCode has a quite good guess here. Mypy seems guessing
a
is object.Actual Behavior
Your Environment
mypy.ini
(and other config files): in playground