Skip to content
Closed
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
3 changes: 2 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,8 @@ def check_return_stmt(self, s: ReturnStmt) -> None:
if self.is_unusable_type(return_type):
# Lambdas are allowed to have a unusable returns.
# Functions returning a value of type None are allowed to have a Void return.
if isinstance(self.scope.top_function(), FuncExpr) or isinstance(typ, NoneTyp):
if isinstance(self.scope.top_function(), FuncExpr) or \
isinstance(typ, (NoneTyp, Void)):
return
self.fail(messages.NO_RETURN_VALUE_EXPECTED, s)
else:
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-statements.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import typing
def f() -> None:
return None
def g() -> None:
return f() # E: No return value expected
return f()
[out]

[case testReturnInGenerator]
Expand Down