-
Notifications
You must be signed in to change notification settings - Fork 771
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
AsyncGenerator abstractmethods typechecked as coroutine incorrectly #2287
Comments
The problem is that the abstract method is missing a For what it's worth, mypy issues the same error in this case. |
Thanks, @erictraut ! This seems like a less common usage, so thanks for addressing it. |
I've added special-case code to handle this condition. It will be fixed in the next release. |
This issue was fixed in version 2022.1.5. You can find the changelog here: CHANGELOG.md |
This still appears to be a problem. Here is a minimum example: from abc import abstractmethod
from collections.abc import AsyncGenerator
class A():
@abstractmethod
async def foo() -> AsyncGenerator[int, None]:
pass
async def bar(self):
generator = self.foo()
async for i in generator:
print(i) I am on the vscode pylance extension version v2024.11.3 |
It seems the from abc import abstractmethod
from collections.abc import AsyncGenerator
class A():
@abstractmethod
async def foo() -> AsyncGenerator[int, None]:
...
async def bar(self):
generator = self.foo()
async for i in generator:
print(i) |
I'm trying to define an abstract base class with an
abstractmethod
that returns anAsyncGenerator
. The typechecker appears to operate inconsistently between usages of the abstract base vs concrete implementations.E.g.
Removing
async
from theabstractmethod
causes the error to disappear, but I don't believe this is the correct annotation (and pylint also reports it as an error that the base class signature does not match the concrete class). This doesn't appear to report an error when running pyright 1.1.208 directly.pyrightconfig.json:
I'm running Pylance v2022.1.3 on VS Code Version: 1.63.2 (Universal) (Mac OS)
The text was updated successfully, but these errors were encountered: