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

Bug: C419 incorrectly tries to remove list comprehension in async for #12891

Closed
MarkusSintonen opened this issue Aug 14, 2024 · 0 comments · Fixed by #12895
Closed

Bug: C419 incorrectly tries to remove list comprehension in async for #12891

MarkusSintonen opened this issue Aug 14, 2024 · 0 comments · Fixed by #12895
Labels
bug Something isn't working help wanted Contributions especially welcome

Comments

@MarkusSintonen
Copy link

MarkusSintonen commented Aug 14, 2024

Following code gives an incorrect linting error:

from collections.abc import AsyncGenerator


async def test() -> None:
    async def async_gen() -> AsyncGenerator[bool, None]:
        yield True

    assert all([v async for v in async_gen()])  # C419 Unnecessary list comprehension

Removing the list comprehension here is incorrect as all can not take an async generator.
Changing it into all(v async for v in async_gen()) gives: TypeError: 'async_generator' object is not iterable

Using Ruff version 0.5.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Contributions especially welcome
Projects
None yet
2 participants