Skip to content

SIM113 false positive with async for loops #9995

@adrienball

Description

@adrienball

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions