-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Rule for async without await #339
Comments
This kind of exists in the form of ASYNC910, though that will flag a lot more than just functions without Agree that autofix is not really on the table. But I'm not opposed to adding it to flake8-async itself, and even for ruff it kind of fits better among the other async rules than randomly among their own. Implementing it should be straightforward, only complication would be if we want it to interact with ASYNC9xx and suppress ASYNC9xx if async-no-await is raised. |
Thanks, I did not know about RUF029. Something I noticed while trying that is that is only seems to work for simple functions and not for methods on a class - would be great to be able to lint both of these. |
|
I suppose we could have two rules then, one for functions and one for class methods, with accompanying blurbs about their optional-ness. |
One other situation that might be worth excluding is functions with decorators applied, since those probably also expect a specific interface. Although of course many don't or are adaptive between sync/async. |
Hi, I'm wondering what you think about adding a rule to catch async functions that have no await statements - and which could therefore be changed into sync functions for a small performance and simplicity gain.
It could work in the same way as this no-async-without-await rule in TSLint: https://palantir.github.io/tslint/rules/no-async-without-await/#:~:text=Marking%20a%20function%20as%20async,keyword%20is%20there%20by%20mistake.
Of course there may be instances where a function needs to be async to satisfy some external interface. But in all other cases, it would be useful to have a way to scan for pointless async functions.
I don't think an auto-fix would be very simple since the call sites also need to be updated, but flagging as a warning for manual fixing would be helpful.
The text was updated successfully, but these errors were encountered: