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

Lambda inference #3097

Closed
hasufell opened this issue Mar 31, 2017 · 1 comment
Closed

Lambda inference #3097

hasufell opened this issue Mar 31, 2017 · 1 comment
Labels
bug mypy got something wrong priority-2-low

Comments

@hasufell
Copy link
Contributor

Sorry I didn't look through all issues, so this migh very well be a duplicate.

This should be rejected by MyPy (which is true for pytype btw):

def foo(a : int) -> str:
    return (lambda x: x + 1)(a)

x in the lambda can only ever be of type int anyway, so the result of the whole expression can only be int as well, never str.

@JukkaL
Copy link
Collaborator

JukkaL commented Mar 31, 2017

Yes, this seems like a mypy bug. The technical explanation is that mypy doesn't use information from the surrounding call expression as part of the type context for the lambda expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-2-low
Projects
None yet
Development

No branches or pull requests

2 participants