Skip to content
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

PLW0120 false positive for/with/break/else #3019

Closed
pawamoy opened this issue Feb 18, 2023 · 1 comment · Fixed by #3032
Closed

PLW0120 false positive for/with/break/else #3019

pawamoy opened this issue Feb 18, 2023 · 1 comment · Fixed by #3032
Assignees
Labels
bug Something isn't working

Comments

@pawamoy
Copy link

pawamoy commented Feb 18, 2023

  • A minimal code snippet that reproduces the bug.
from contextlib import suppress

for name in ["demo"]:
    with suppress(AttributeError, KeyError):
        thing = name
        break
else:
    thing = "other stuff"
  • The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.
% ruff demo.py
demo.py:1:1: D100 Missing docstring in public module
demo.py:7:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it
Found 2 errors.
  • The current Ruff settings (any relevant sections from your pyproject.toml).

Just enabling a bunch of letters, plus targeting Python 3.7.

  • The current Ruff version (ruff --version).
% ruff --version
ruff 0.0.247
@charliermarsh charliermarsh added the bug Something isn't working label Feb 18, 2023
@charliermarsh
Copy link
Member

Thanks! Looks like a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants