Skip to content

Commit

Permalink
empty generator *functions*
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
ikonst and AlexWaygood authored Jul 20, 2023
1 parent a64254c commit 6d20704
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,8 +1235,9 @@ def check_func_def(
new_frame.types[key] = narrowed_type
self.binder.declarations[key] = old_binder.declarations[key]
with self.scope.push_function(defn):
# We suppress reachability warnings for empty generators (return; yield), since there's
# no way to promote a function into a generator except by adding an "unreachable" yield.
# We suppress reachability warnings for empty generator functions
# (return; yield), since the most idiomatic way to promote a function into a
# generator function is often to add an "unreachable" yield.
#
# We also suppress reachability warnings when we use TypeVars with value
# restrictions: we only want to report a warning if a certain statement is
Expand Down

0 comments on commit 6d20704

Please sign in to comment.