false negative `reportUnusedCoroutine` when assigned to `_`
Description
Code sample in basedpyright playground
async def f():
await f()
f() # not awaited
_ = f() # no error
i would think assigning it to _ indicates that you're explicitly ignoring the coroutine, just like with reportUnusedCallResult.
the eslint equivalent rule @typescript-eslint/no-floating-promises has a similar feature where you can use the void keyword to explicitly ignore the promise.
it's a runtime crash to not await a coroutine
from asyncio import run
async def f():
f2()
async def f2(): pass
run(f())
its a RuntimeWarning not a crash:
/home/me/projects/test/asdf.py:6: RuntimeWarning: coroutine 'f' was never awaited
f()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
but on second thought it probably does make sense to report an error here, since the assignment to _ is intended to explicitly ignore the result. but in the case of a coroutine with a return value, you would still want an error that you aren't awaiting the result before discarding it
yeah, exactly. it should be
_ = await f()
in an ideal world we would track which values are awaited or not at the type level, just like unassigned variables