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 of compose with generic functions fails #16

Open
suned opened this issue Sep 15, 2019 · 0 comments
Open

Type inference of compose with generic functions fails #16

suned opened this issue Sep 15, 2019 · 0 comments
Labels
bug Something isn't working MyPy

Comments

@suned
Copy link
Owner

suned commented Sep 15, 2019

E.g

from typing import TypeVar
from pfun import compose

A = TypeVar('A')

def f(a: A) -> A:
    pass

def g(a: int) -> str:
    pass

compose(f, g)  # error: Cannot infer argument 1 of compose

I think this is a current limitation of the mypy inference, since this also does not work:

R1 = TypeVar('R1')
R2 = TypeVar('R2')
R3 = TypeVar('R3')

def compose(f: Callable[[R2], R1], g: Callable[[R3], R2]) -> Callable[[R3], R1]:
    pass

A = TypeVar('A')

def f(a: A) -> A:
    pass

def g(a: int) -> str:
    pass

compose(f, g)  # error: Cannot infer type of argument 1 of compose
@suned suned added bug Something isn't working MyPy labels Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working MyPy
Projects
None yet
Development

No branches or pull requests

1 participant