-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
intentionally empty generator marked as unreachable #15345
Comments
Uum... I couldn't reproduce this bug.
❯ mypy --warn-unreachable t.py
Success: no issues found in 1 source file
❯ cat t.py
from typing import Generator
def f() -> Generator[None, None, None]:
yield from ()
|
yes you've used the workaround. |
What could be a good heuristic here? That an empty yield statement (without expression) is explicitly allowed to trail a return statement? |
I'm not sure -- I think the only case is specifically the one in the issue -- I can't think of others since if it were conditional then there'd probably be a yield in the other arm. maybe this is specifically a cutout for |
How about every function having a budget for one bare yield that doesn't get flagged? |
Planning to address it on top of #15386. |
Bug Report
this seems to be a common pattern:
it can instead be rewritten as:
To Reproduce
see above
Expected Behavior
(no errors)
Actual Behavior
Your Environment
--warn-unreachable
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: