Skip to content

Commit 82e8c8c

Browse files
ikonstAlexWaygood
andauthored
empty generator *function*
Co-authored-by: Alex Waygood <[email protected]>
1 parent 6d20704 commit 82e8c8c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mypy/checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ def check_func_def(
12451245
# have no good way of doing this.
12461246
#
12471247
# TODO: Find a way of working around this limitation
1248-
if _is_empty_generator(item) or len(expanded) >= 2:
1248+
if _is_empty_generator_function(item) or len(expanded) >= 2:
12491249
self.binder.suppress_unreachable_warnings()
12501250
self.accept(item.body)
12511251
unreachable = self.binder.is_unreachable()
@@ -6966,7 +6966,7 @@ def is_literal_not_implemented(n: Expression) -> bool:
69666966
return isinstance(n, NameExpr) and n.fullname == "builtins.NotImplemented"
69676967

69686968

6969-
def _is_empty_generator(func: FuncItem) -> bool:
6969+
def _is_empty_generator_function(func: FuncItem) -> bool:
69706970
"""
69716971
Checks whether a function's body is 'return; yield' (the yield being added only
69726972
to promote the function into a generator).

test-data/unit/check-unreachable-code.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,15 +1447,15 @@ def f() -> None:
14471447
x = 0 # This should not be reported as unreachable
14481448
[builtins fixtures/exception.pyi]
14491449

1450-
[case testIntentionallyEmptyGenerator]
1450+
[case testIntentionallyEmptyGeneratorFunction]
14511451
# flags: --warn-unreachable
14521452
from typing import Generator
14531453

14541454
def f() -> Generator[None, None, None]:
14551455
return
14561456
yield
14571457

1458-
[case testIntentionallyEmptyGenerator_None]
1458+
[case testIntentionallyEmptyGeneratorFunction_None]
14591459
# flags: --warn-unreachable
14601460
from typing import Generator
14611461

0 commit comments

Comments
 (0)