8000 Check implicit None return is valid when using `--no-warn-no-return` by hauntsaninja · Pull Request #13219 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Check implicit None return is valid when using --no-warn-no-return #13219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 27, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Merge remote-tracking branch 'origin/master' into check-none-no-return
  • Loading branch information
hauntsaninja committed Jul 27, 2022
commit 9570a39fecfde46c85fbd686d8230e937c187c07
17 changes: 10 additions & 7 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,10 +1218,12 @@ def check_func_def(self, defn: FuncItem, typ: CallableType, name: Optional[str])
unreachable = self.binder.is_unreachable()

if not unreachable and not body_is_trivial:
if (defn.is_generator or
is_named_instance(self.return_types[-1], 'typing.AwaitableGenerator')):
return_type = self.get_generator_return_type(self.return_types[-1],
defn.is_coroutine)
if defn.is_generator or is_named_instance(
self.return_types[-1], "typing.AwaitableGenerator"
):
return_type = self.get_generator_return_type(
self.return_types[-1], defn.is_coroutine
)
elif defn.is_coroutine:
return_type = self.get_coroutine_return_type(self.return_types[-1])
else:
Expand All @@ -1241,13 +1243,14 @@ def check_func_def(self, defn: FuncItem, typ: CallableType, name: Optional[str])
else:
# similar to code in check_return_stmt
self.check_subtype(
subtype_label='implicitly returns',
subtype_label="implicitly returns",
subtype=NoneType(),
supertype_label='expected',
supertype_label="expected",
supertype=return_type,
context=defn,
msg=message_registry.INCOMPATIBLE_RETURN_VALUE_TYPE,
code=codes.RETURN_VALUE)
code=codes.RETURN_VALUE,
)

self.return_types.pop()

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0