-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Consider the following code:
# test.py
import asyncio
from contextlib import asynccontextmanager
from typing import AsyncIterator
@asynccontextmanager
async def manager() -> AsyncIterator[int]:
yield 1
async def main() -> None:
async with (
manager(),
):
print("Hello!")
asyncio.run(main())Running pyright test.py gives:
./test.py
./test.py:13:16 - error: Object of type "tuple[_AsyncGeneratorContextManager[int, None]]" cannot be used with "async with" because it does not correctly implement __aenter__
Attribute "__aenter__" is unknown (reportGeneralTypeIssues)
./test.py:13:16 - error: Object of type "tuple[_AsyncGeneratorContextManager[int, None]]" cannot be used with "with" because it does not correctly implement __aexit__
Attribute "__aexit__" is unknown (reportGeneralTypeIssues)
2 errors, 0 warnings, 0 informations
The code is valid and prints "Hello!" as expected, but Pyright seems to have an issue with the context manager.
Am I missing something or is this a bug?
I'm using pyright==1.1.406.
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