We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Bug Report Mypy reports an incompatible type error when using a generic asynccontextmanager. When using the non-async equivalent there is no error.
To Reproduce
from typing import Type, TypeVar, AsyncIterator, Iterator, Generic import contextlib T = TypeVar("T") @contextlib.contextmanager def create(my_type: Type[T]) -> Iterator[T]: yield my_type() @contextlib.asynccontextmanager async def async_create(my_type: Type[T]) -> AsyncIterator[T]: yield my_type() class Foo(Generic[T]): def do_something(self, t: T) -> None: pass def example(self, my_type: Type[T]) -> None: with create(my_type) as value1: self.do_something(value1) async def async_example(self, my_type: Type[T]) -> None: async with async_create(my_type) as value2: self.do_something(value2)
Mypy reports error: Incompatible types in assignment (expression has type "T", variable has type "T") for the self.do_something(value2) line.
error: Incompatible types in assignment (expression has type "T", variable has type "T")
self.do_something(value2)
Expected Behavior No error for the above example
Your Environment
The text was updated successfully, but these errors were encountered:
I think fixed on master by #11352
Sorry, something went wrong.
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
Mypy reports an incompatible type error when using a generic asynccontextmanager. When using the non-async equivalent there is no error.
To Reproduce
Mypy reports
error: Incompatible types in assignment (expression has type "T", variable has type "T")
for theself.do_something(value2)
line.Expected Behavior
No error for the above example
Your Environment
The text was updated successfully, but these errors were encountered: