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

Type inference problem with generic function with type variable type as return type #462

Closed
JukkaL opened this issue Sep 22, 2014 · 0 comments
Labels
bug mypy got something wrong

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Sep 22, 2014

Consider this code:

from typing import typevar, List
T = typevar('T')
def f(x: List[T]) -> T: return x[0]
def g(y: object) -> None: pass
a = [1]
g(f(a))  # Argument 1 to "f" has incompatible type List[int]; expected List[object]

The code should not be rejected. We should not infer T from the context of the f invocation.

This is a generalization of #360.

@JukkaL JukkaL added bug mypy got something wrong priority labels Sep 22, 2014
JukkaL added a commit that referenced this issue Oct 25, 2014
@JukkaL JukkaL closed this as completed in 75d2e01 Oct 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant