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
Feature
Extend unused-coroutine to also encompass directly using the unawaited result with if/while, or perhaps also in other instances where it's used as a condition such as boolean operations etc. Or since the return value technically is used, introduce another error code.
Pitch
Currently no warning is raised for the following code:
asyncdeffoo() ->bool:
returnFalseiffoo():
print("foo is true!")
because the return value of the coroutine technically is used. But it's very clearly an error, will give a RuntimeWarning, and bool(foo()) always evaluates to True.
I also have a hard time coming up with reasonable scenarios where the above functionality is desired, other than perhaps some weird logic for figuring out if a function is async or not - but in that case the object should be a union of those types and the type checker should be able to handle it.
The text was updated successfully, but these errors were encountered:
Feature
Extend
unused-coroutine
to also encompass directly using the unawaited result with if/while, or perhaps also in other instances where it's used as a condition such as boolean operations etc. Or since the return value technically is used, introduce another error code.Pitch
Currently no warning is raised for the following code:
because the return value of the coroutine technically is used. But it's very clearly an error, will give a
RuntimeWarning
, andbool(foo())
always evaluates toTrue
.I also have a hard time coming up with reasonable scenarios where the above functionality is desired, other than perhaps some weird logic for figuring out if a function is async or not - but in that case the object should be a union of those types and the type checker should be able to handle it.
The text was updated successfully, but these errors were encountered: