-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Awaitablity checks not fully complete #6053
Copy link
Copy link
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
Describe the bug
Pyright's checks for whether an object is awaitable are not fully in line with python's. This code runs fine at runtime but type errors
Code or Screenshots
import asyncio
import collections.abc
import contextvars
from typing import Self
class WrapCoro(collections.abc.Coroutine):
def __init__(self, coro, context):
self._coro = coro
self._context = context
def __await__(self) -> Self:
return self
def __iter__(self) -> Self:
return self
def __next__(self):
return self.send(None)
def throw(self, *exc_info):
result = self._context.run(self._coro.throw, *exc_info)
return result
def send(self, v):
result = self._context.run(self._coro.send, v)
return result
async def coro():
...
async def foo():
await WrapCoro(coro(), contextvars.copy_context()) # warning that WrapCoro is not awaitable
asyncio.run(foo())VS Code extension or command-line
pyright 1.1.328
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working