Skip to content

Commit aa5d0d7

Browse files
Fix typing issue for our aclosing implementation.
1 parent da05f66 commit aa5d0d7

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/prompt_toolkit/eventloop/async_generator.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from threading import Event
66
from typing import (
77
TYPE_CHECKING,
8+
Any,
89
AsyncGenerator,
910
Awaitable,
1011
Callable,
@@ -21,22 +22,13 @@
2122
"generator_to_async_generator",
2223
]
2324

24-
25-
if TYPE_CHECKING:
26-
# Thanks: https://github.com/python/typeshed/blob/main/stdlib/contextlib.pyi
27-
from typing_extensions import Protocol
28-
29-
class _SupportsAclose(Protocol):
30-
def aclose(self) -> Awaitable[object]:
31-
...
32-
33-
_SupportsAcloseT = TypeVar("_SupportsAcloseT", bound=_SupportsAclose)
25+
_T_Generator = TypeVar("_T_Generator", bound=AsyncGenerator[Any, None])
3426

3527

3628
@asynccontextmanager
3729
async def aclosing(
38-
thing: "_SupportsAcloseT",
39-
) -> AsyncGenerator["_SupportsAcloseT", None]:
30+
thing: _T_Generator,
31+
) -> AsyncGenerator[_T_Generator, None]:
4032
"Similar to `contextlib.aclosing`, in Python 3.10."
4133
try:
4234
yield thing

0 commit comments

Comments
 (0)