Skip to content

Check B007 and B020 on async for loops too - #645

Open
Vineet829 wants to merge 2 commits into
PyCQA:mainfrom
Vineet829:check-b007-b020-async-for
Open

Vineet829 wants to merge 2 commits into
PyCQA:mainfrom
Vineet829:check-b007-b020-async-for

Conversation

@Vineet829

Copy link
Copy Markdown

visit_For calls check_for_b007 and check_for_b020, but visit_AsyncFor only calls the B045 and B023 checks, so an unused loop variable or a loop that rebinds its own iterable isn't reported when the loop is async for:

async def f(xs, items):
    async for i in xs:
        print("tick")
    async for items in items:
        print(items)

On main this file gives no errors. The same loops without async give B007 on line 2 and B020 on line 4. Now the async loops get both too. I left B031, B909 and B913 out: they are about groupby(), mutating a list, dict or set, and zip(), and async for raises a TypeError on each of those. That includes the async for k in d.keys() case mentioned in the review of #596. Added async cases to tests/eval_files/b007.py and b020.py and a changelog line.

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 this pull request may close these issues.

1 participant