-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Searched keywords: PERF402. #10322 is similar, but more complicated (and closed by the submitter).
This code triggers PERF402 on ruff 0.3.5:
from typing import AsyncIterator
async def some_async_iterable() -> AsyncIterator[int]:
for i in range(10):
yield i
async def foo() -> None:
values: list[int] = []
async for i in some_async_iterable():
values.append(i)Result from running ruff check --isolated --select PERF402:
bug.py:12:9: PERF402 Use `list` or `list.copy` to create a copy of a list
Found 1 error.
But list and list.copy cannot be used on an async iterator. #10322 suggested using an async list comprehension, but I think that's a different animal; in the very least the error message is wrong, and a check that would suggest using a list comprehension instead of a loop would be rather different in spirit.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule