KEMBAR78
Lambda inference · Issue #3097 · python/mypy · GitHub
Skip to content

Lambda inference #3097

@hasufell

Description

@hasufell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions