Skip to content

Avoid crash on lamba (a, b): a with context. Fix #1421 #1452

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

Merged
merged 1 commit into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,8 @@ def visit_func_expr(self, e: FuncExpr) -> Type:
else:
# Type context available.
self.chk.check_func_item(e, type_override=inferred_type)
if e.expr() not in self.chk.type_map:
self.accept(e.expr())
ret_type = self.chk.type_map[e.expr()]
return replace_callable_return_type(inferred_type, ret_type)

Expand Down
8 changes: 8 additions & 0 deletions mypy/test/data/check-python2.test
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,11 @@ def f((x,)): return x
def g((x)): return x
f(0) + g(0)
[out]

[case testLambdaAsSortKeyForTuplePython2]
from typing import Any, Tuple, Callable
def bar(key: Callable[[Tuple[int, int]], int]) -> int:
pass
def foo() -> int:
return bar(key=lambda (a, b): a)
[out]