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

[flake8-async] Fix false positives with multiple async with items (ASYNC100) #12643

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

bluetech
Copy link
Contributor

@bluetech bluetech commented Aug 2, 2024

Summary

Please see #12605 (comment) for a description of the issue.

They way I fixed it is to get the last timeout item in the with, and if it's an async with and there are items after it, then don't trigger the lint.

Test Plan

Updated the fixture with some more cases.



async def func():
async with trio.fail_after():
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trio and anyio context managers are not async. The difference is relevant for this change, so I changed them back to with, this way we test both with and async with (asyncio).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's my bad!

Copy link
Contributor

github-actions bot commented Aug 2, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever, thanks!

@charliermarsh charliermarsh enabled auto-merge (squash) August 2, 2024 21:21
@charliermarsh charliermarsh merged commit fbfe2cb into astral-sh:main Aug 2, 2024
18 checks passed
@bluetech bluetech deleted the async100-multi-item branch August 4, 2024 13:20
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.

2 participants