Skip to content

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

Merged
charliermarsh merged 2 commits intoastral-sh:mainfrom
bluetech:async100-multi-item
Aug 2, 2024
Merged

[flake8-async] Fix false positives with multiple async with items (ASYNC100)#12643
charliermarsh merged 2 commits intoastral-sh:mainfrom
bluetech:async100-multi-item

Conversation

@bluetech
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

@github-actions
Copy link
Copy Markdown
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
Copy Markdown
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
@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