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

PERF203 should only trigger if loop control flow isn't in the try block #6535

Closed
evanrittenhouse opened this issue Aug 13, 2023 · 1 comment · Fixed by #6536
Closed

PERF203 should only trigger if loop control flow isn't in the try block #6535

evanrittenhouse opened this issue Aug 13, 2023 · 1 comment · Fixed by #6536

Comments

@evanrittenhouse
Copy link
Contributor

Copied from #4789 (comment):

PERF203 should only trigger when there’s no loop flow control (break, continue) in the try-catch statement. E.g. I don’t think there’s a better way to write the following:

for repo in ['R-patched', 'cran', 'bioc']:
    try:
        pkg_cache = self._fetch_cache(repo, pkg)
        break
    except HTTPError:
        pass
else:
    return None
@trim21
Copy link
Contributor

trim21 commented Sep 16, 2024

I just find that this false positive still exists, but only on certain target-version.

it pass with target-version = 'py311' but failed with target-version = 'py38'

https://play.ruff.rs/eadb6e43-5f78-4bcd-93f3-2d409bdbf4c8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants