Skip to content

Commit

Permalink
less walrus
Browse files Browse the repository at this point in the history
  • Loading branch information
ikonst committed Jul 20, 2023
1 parent 5e33f47 commit ebc1cfa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6970,8 +6970,9 @@ def _is_empty_generator(func: FuncItem) -> bool:
Checks whether a function's body is 'return; yield' (the yield being added only
to promote the function into a generator).
"""
body = func.body.body
return (
len(body := func.body.body) == 2
len(body) == 2
and isinstance(ret_stmt := body[0], ReturnStmt)
and (ret_stmt.expr is None or is_literal_none(ret_stmt.expr))
and isinstance(expr_stmt := body[1], ExpressionStmt)
Expand Down

0 comments on commit ebc1cfa

Please sign in to comment.