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

SIM113 false positive with async for loops #9995

Closed
adrienball opened this issue Feb 15, 2024 · 1 comment · Fixed by #9996
Closed

SIM113 false positive with async for loops #9995

adrienball opened this issue Feb 15, 2024 · 1 comment · Fixed by #9996
Labels
bug Something isn't working

Comments

@adrienball
Copy link
Contributor

Steps to reproduce

  • Create a debug.py file with the following content:
async def my_async_gen():
    for i in range(5):
        yield i


async def my_async_func():
    idx = 0
    async for v in my_async_gen():
        idx += 1
        print(f"{idx}: {v}")
  • Run ruff check debug.py

Expected behavior

No error

Actual behavior

debug.py:9:9: SIM113 Use `enumerate()` for index variable `idx` in `for` loop
Found 1 error.

Environment

> ruff --version
ruff 0.2.1
@charliermarsh
Copy link
Member

Ahh, nice catch!

charliermarsh pushed a commit that referenced this issue Feb 16, 2024
## Summary
Ignore `async for` loops when checking the SIM113 rule.

Closes #9995 

## Test Plan
A new test case was added to SIM113.py with an async for loop.
nkxxll pushed a commit to nkxxll/ruff that referenced this issue Mar 10, 2024
## Summary
Ignore `async for` loops when checking the SIM113 rule.

Closes astral-sh#9995 

## Test Plan
A new test case was added to SIM113.py with an async for loop.
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