Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid type inferred for call with *args and generic inheritance #3955

Open
JukkaL opened this issue Sep 14, 2017 · 2 comments
Open

Invalid type inferred for call with *args and generic inheritance #3955

JukkaL opened this issue Sep 14, 2017 · 2 comments

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Sep 14, 2017

Invalid types are inferred for f(*expr) below:

from typing import Iterable, Iterator, Tuple, TypeVar

T = TypeVar('T')
S = TypeVar('S')

class C(Iterable[Tuple[T, S]]):
    def __iter__(self) -> Iterator[Tuple[T, S]]: pass

def f(*x: T) -> T: pass

x: C[str, int]
y: C[int, int]
reveal_type(f(*x))  # str, should be Tuple[str, int]
reveal_type(f(*y))  # int, should be Tuple[int, int]

The problem seems to be related to type inference of *args in calls where there is non-trivial generic inheritance from Iterable such as in C above.

Originally reported as python/typeshed#1600.

@ilevkivskyi
Copy link
Member

This was actually originally reported in #3943

@erictraut
Copy link

This appears to be fixed. It now produces the expected results. (Note: the last line in the code sample above should say "should be Tuple[int, int]".)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants