8000 [`flake8_async`] Fix sleep argument name for anyio (`ASYNC115`, `ASYNC116`) by Vasanth-96 · Pull Request #18262 · astral-sh/ruff · GitHub
[go: up one dir, main page]

Skip to content

[flake8_async] Fix sleep argument name for anyio (ASYNC115, ASYNC116) #18262

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

Conversation

Vasanth-96
Copy link
Contributor
@Vasanth-96 Vasanth-96 commented May 22, 2025

#18164

Summary

Fix incorrect argument name detection for anyio.sleep and trio.sleep in ASYNC115 lint check.
The linter previously assumed the keyword argument for sleep duration was always seconds, causing false positives when delay was used with anyio.sleep.
This update correctly distinguishes between seconds (Trio) and delay (AnyIO), improving accuracy.

Fixes #18164

Test Plan

  • Added test cases covering both anyio.sleep(delay=0) and trio.sleep(seconds=0) usage.
  • Verified ASYNC115 warnings are correctly triggered or suppressed based on argument names.
  • Manual testing with examples from the linked issue.

@MichaReiser
Copy link
Member

Would you mind filling in the summary and test plan section of your PR? It would help us review your change

@Vasanth-96
Copy link
Contributor Author

Apologies for the delay — I got caught up with work and wasn’t able to write the tests or summary yet. I’ll update it shortly.

Copy link
Member
@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Thanks and also thank you for updating the summary. It helped me a lot to this PR a lot!

I think we should change the added tests because they currently wouldn't catch a regression (they're all okay). I think it's as easy as changing the argument provided to sleep/delay to 0 (which makes the rule trigger).

@Vasanth-96
Copy link
Contributor Author

done @MichaReiser thank you very much for the review, have updated the tests.

@MichaReiser MichaReiser added bug Something isn't working rule Implementing or modifying a lint rule labels May 26, 2025
@MichaReiser MichaReiser enabled auto-merge (squash) May 26, 2025 08:44
auto-merge was automatically disabled May 26, 2025 09:24

Pull request was closed

@MichaReiser MichaReiser reopened this May 26, 2025
@MichaReiser MichaReiser enabled auto-merge (squash) May 26, 2025 09:24
Copy link
Contributor
github-actions bot commented May 26, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser changed the title [flake8_async] Refactor argument name resolution for async sleep func… [flake8_async] Fix sleep argument name for anyio (ASYNC115, ASYNC116) May 26, 2025
@MichaReiser MichaReiser merged commit d078ecf into astral-sh:main May 26, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ASYNC115 and ASYNC116 check the wrong argument name for anyio.sleep
3 participants
0