Skip to content
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
6 changes: 5 additions & 1 deletion mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
self.check_protocol_issubclass(e)
if isinstance(ret_type, UninhabitedType) and not ret_type.ambiguous:
self.chk.binder.unreachable()
if not allow_none_return and self.always_returns_none(e.callee):
# Warn on calls to functions that always return None. The check
# of ret_type is both a common-case optimization and prevents reporting
# the error in dynamic functions (where it will be Any).
if (not allow_none_return and isinstance(ret_type, NoneTyp)
and self.always_returns_none(e.callee)):
self.chk.msg.does_not_return_value(callee_type, e)
return AnyType(TypeOfAny.from_error)
return ret_type
Expand Down
7 changes: 7 additions & 0 deletions test-data/unit/check-functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -2376,3 +2376,10 @@ def Y(x: Optional[str] = X(x_in)): ...

xx: Optional[int] = X(x_in)
[out]

[case testNoComplainNoneReturnFromUntyped]
def foo() -> None:
pass

def lol():
x = foo()