You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ASYNC100-version of ASYNC91x, i.e. the trivial case where there is no await/async [for/with] in a method at all. As opposed to ASYNC91x this could be default-enabled, will be relevant for asyncio users, and should be much less noisy.
We could silence 910 and 911 for the trivial case to mirror async100/async912, or expect users to disable async-func-no-await when enabling 910 & 911.
Examples:
# currently raises 910, would raise async-func-no-awaitasyncdeffoo():
print("bar")
# would only raise 910asyncdefbar():
if ...:
awaitfoo()
# async-func-no-await does not care about func vs generator# raises 911 and async-func-no-awaitasyncdeffoo_gen():
yield"hello"# does not give any warningsasyncdeffoo_always():
if ...:
awaitfoo()
else:
awaitbar()
Shoutout to @oremanj for giving inspiration for it in gitter.
I think it is still a good idea for linters to insist that every async function await something, because async functions are more expensive to call than synchronous functions, and if it doesn't await anything then it should just be synchronous. In order to get a checkpoint guarantee you need to await something on every path; this is definitely helpful if you use Trio (or if you're writing an anyio library that people might use on Trio), but it's hard to argue that it provides any meaningful benefit on asyncio when the built-in functions don't follow the rule.
The text was updated successfully, but these errors were encountered:
The ASYNC100-version of ASYNC91x, i.e. the trivial case where there is no
await
/async [for/with]
in a method at all. As opposed to ASYNC91x this could be default-enabled, will be relevant for asyncio users, and should be much less noisy.We could silence 910 and 911 for the trivial case to mirror async100/async912, or expect users to disable async-func-no-await when enabling 910 & 911.
Examples:
Shoutout to @oremanj for giving inspiration for it in gitter.
The text was updated successfully, but these errors were encountered: