Skip to content

False positives due to incorrect async with semantics #367

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

Closed
tim-becker opened this issue Apr 3, 2025 · 1 comment · Fixed by #371
Closed

False positives due to incorrect async with semantics #367

tim-becker opened this issue Apr 3, 2025 · 1 comment · Fixed by #371

Comments

@tim-becker
Copy link

flake8-async seems to generally handle async with statements with multiple items incorrectly.

Below is an example demonstrating a false positive detection of ASYNC100, but this surely affects many other rules as well (e.g. ASYNC912)

import asyncio

async def main():
    async with asyncio.timeout(1), asyncio.TaskGroup() as tg: # noqa: ASYNC100 ; false positive because tg.__aexit__ occurs within timeout scope
        _ = tg.create_task(asyncio.sleep(2))

asyncio.run(main())
@jakkdl
Copy link
Member

jakkdl commented Apr 17, 2025

Good catch! Yeah visitor91x currently treats async with statements as a single blob and doesn't consider interactions between the WithItems. I've got a fix in-progress :)

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 a pull request may close this issue.

2 participants