Skip to content

Commit a64254c

Browse files
author
Ilya Priven
committed
make the TODO-remove part second
1 parent ebc1cfa commit a64254c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mypy/checker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,16 +1235,16 @@ def check_func_def(
12351235
new_frame.types[key] = narrowed_type
12361236
self.binder.declarations[key] = old_binder.declarations[key]
12371237
with self.scope.push_function(defn):
1238-
# We suppress reachability warnings when we use TypeVars with value
1238+
# We suppress reachability warnings for empty generators (return; yield), since there's
1239+
# no way to promote a function into a generator except by adding an "unreachable" yield.
1240+
#
1241+
# We also suppress reachability warnings when we use TypeVars with value
12391242
# restrictions: we only want to report a warning if a certain statement is
12401243
# marked as being suppressed in *all* of the expansions, but we currently
12411244
# have no good way of doing this.
12421245
#
12431246
# TODO: Find a way of working around this limitation
1244-
#
1245-
# We suppress reachability warnings for empty generators (return; yield), since there's
1246-
# no way to promote a function into a generator except by adding an "unreachable" yield.
1247-
if len(expanded) >= 2 or _is_empty_generator(item):
1247+
if _is_empty_generator(item) or len(expanded) >= 2:
12481248
self.binder.suppress_unreachable_warnings()
12491249
self.accept(item.body)
12501250
unreachable = self.binder.is_unreachable()

0 commit comments

Comments
 (0)