Do not emit return errors if node is deferred
Motivation
If a variable is unknown / the function node deferred, mypy should not emit Implicit return in function which does not return or Missing return statement errors.
Assume current_app.aborter is a NoReturn method and the function node gets deferred because of current_app. There should not be an Implicit return in function which does not return error (assuming the option warn_no_return is enabled).
def abort(code: int, *args: Any, **kwargs: Any) -> "NoReturn":
current_app.aborter(code, *args, **kwargs)
An example (, that was given by @davidism) can be found in the Flask abort function.
See https://github.com/python/mypy/issues/12779 for more details.
Implementation
Ensure to check self.current_node_deferred before emitting the errors.
Test Plan
I already tried to create a test case, but could not produce an example where var.is_ready is False (-> function gets deferred). Does anyone has an idea how to create a such a case on purpose?
Closes https://github.com/python/mypy/issues/12779
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉