diff --git a/mypy/checker.py b/mypy/checker.py index 97d215e3d28b..a810d8f6b335 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -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: diff --git a/test-data/unit/check-statements.test b/test-data/unit/check-statements.test index 1fa0cdcc6342..3660606fcd7d 100644 --- a/test-data/unit/check-statements.test +++ b/test-data/unit/check-statements.test @@ -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]