8000 Always allow returning Any from lambda (#15413) · coderabbit-test/mypy@9e7bc38 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9e7bc38

Browse files
authored
Always allow returning Any from lambda (python#15413)
1 parent a108c67 commit 9e7bc38

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mypy/checker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4270,6 +4270,7 @@ def check_return_stmt(self, s: ReturnStmt) -> None:
42704270
isinstance(return_type, Instance)
42714271
and return_type.type.fullname == "builtins.object"
42724272
)
4273+
and not is_lambda
42734274
):
42744275
self.msg.incorrectly_returning_any(return_type, s)
42754276
return

test-data/unit/check-flags.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,3 +2184,14 @@ def f(x: bytes, y: bytearray, z: memoryview) -> None:
21842184
follow_imports = skip
21852185
follow_imports_for_stubs = true
21862186
[builtins fixtures/dict.pyi]
2187+
2188+
[case testReturnAnyLambda]
2189+
# flags: --warn-return-any
2190+
from typing import Any, Callable
2191+
2192+
def cb(f: Callable[[int], int]) -> None: ...
2193+
a: Any
2194+
cb(lambda x: a) # OK
2195+
2196+
fn = lambda x: a
2197+
cb(fn)

0 commit comments

Comments
 (0)
0