-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add configuration to report any usage of an unawaited coroutine #3563
Comments
This would require introducing a new diagnostic rule because I'm going to close this for now, but we might reconsider in the future if we get signal from enough pyright users that they want this functionality. |
Understandable. We are converting a sync codebase to an async one, which I would imagine is somewhat of a fairly common use case as async/await becomes more mainstream in Python. But i'll wait and see if anyone else has this concern. Thanks |
@erictraut said in: #9086 (comment)
for a reference here are some linters that support this:
async with asyncio.TaskGroup() as tg:
sleep_for = asyncio.sleep(1)
tg.create_task(sleep_for) I'm not sure if pyright can deduce that though...
class Scrapper:
def get_current_task(self) -> Coroutine | None:
...
async def ensure_running(self) -> None:
if not self.get_current_task(): # ✅
await self.start() function returns class Scrapper:
async def get_current_task(self) -> Coroutine | None:
...
async def ensure_running(self) -> None:
if not self.get_current_task(): # 🚨 you should have awaited it
await self.start() |
Is your feature request related to a problem? Please describe.
I've been following #1317, but I'm hoping it would be possible to extend this to support warning/error if you have any unawaited coroutines.
The issue being:
I understand we cannot make the assumption that everyone's workflow requires coroutines to be awaited / it's entirely fine to pass coroutines as a parameter, I'm more just asking if this could be something that's configurable.
The text was updated successfully, but these errors were encountered: