-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Detecting unneeded async
keywords on functions
#9951
Comments
async
keywords`async
keywords on functions
We like this idea :) this is a duplicate of #9833 though |
Doesn't look like it is, the issue you mentioned is for detecting missing What i'm talking about is to detect functions that are defined with the |
Yeah I see, it's a little mixed up over there as we're discussing both things. We can track this separately. @plredmond I'll move you over to this issue. |
async
keywords on functionsasync
keywords on functions
…tects an async function w/o await
In progress implementation: main...plredmond:ruff:issue9951-spurious_async |
…t or async_for or async_with
…ving unused imports
… seem necessary for this rule
…n accept the test snapshot
… bad to have unused asyncs
… the reformatted RUF029 fixture output due to ff5023e
…argument to avoid the posibility of wrong inputs per charlie
…eld to found_await_or_yield
… yields to a fail-case per @carljm (yield does not require async)
… to remove the word yield
… and rename a fail-case
…nction as the problem area
…er finding an async/await (per @MichaReiser)
…cs inside asyncs (fail_4a, fail_4b) with tests having asyncs inside of normal functions (pass_5, fail_4c)
…nctionDef and StmtClass def that do not traverse the body, use them in spurious async to avoid attributing correct /inner/ async functions to incorrect outer functions
…unctions in class definitions using semantic scope info (per @charliermarsh, and thanks to @MichaReiser)
…anation has quotes
## Summary This change adds a rule to detect functions declared `async` but lacking any of `await`, `async with`, or `async for`. This resolves #9951. ## Test Plan This change was tested by following https://docs.astral.sh/ruff/contributing/#rule-testing-fixtures-and-snapshots and adding positive and negative cases for each of `await` vs nothing, `async with` vs `with`, and `async for` vs `for`.
Hello,
I refactored a bunch of code and thought about a rule that could be useful: detecting function defined with the
async
keywords not using anyawait
inside it, example:There's probably some use cases where the async is needed, but, imo, most of the time those async can be removed.
What do you think ?
The text was updated successfully, but these errors were encountered: