Skip to content

Type checking problem with overloaded function, higher order function and typevar values #496

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

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

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 8, 2014

Mypy complains about the following code even though it should be valid:

from typing import typevar, overload, Function

T = typevar('T', values=(int, str))
def f(x: T) -> None:
     m(g, x)  # Error: Argument 1 to "m" has incompatible type functionlike; expected Function[["str"] -> "int"]

A = typevar('A')
R = typevar('R')
def m(f: Function[[A], R], it: A) -> None: pass

@overload
def g(x: int) -> int: return x
@overload
def g(x: str) -> str: return x
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