DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
908 stars 17 forks source link

Support for awaiting "Future like" objects #486

Closed jcorbett-sweater closed 3 weeks ago

jcorbett-sweater commented 1 month ago

Objects with a await method are awaitable "Future like" objects according to PEP-0492

currently basedpyright doesn't recognize a method that returns a "future like" object as awaitable and generates an error saying the object is not awaitable. An example of the objects in the beanie project.

DetachHead commented 1 month ago

could you please provide an example of some code that doesn't work? this minimal example seems to work, so pyright does support __await__ as far as i can tell so maybe there's something wrong with the types in that beanie package?


class Foo:
    def __await__(self):
        yield from range(10)

async def main():
    await Foo()
jcorbett-sweater commented 1 month ago

Sure, I'll get a simple code sample together. It may take me a few days.

KotlinIsland commented 3 weeks ago

@jcorbett-sweater i'm going to close this issue at this time, but feel free to comment and we can reopen, or raise a new issue if you'd like 🙂