mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Make types.coroutine return Awaitable (#6255)
This commit is contained in:
@@ -21,7 +21,7 @@ from typing import (
|
||||
ValuesView,
|
||||
overload,
|
||||
)
|
||||
from typing_extensions import Literal, final
|
||||
from typing_extensions import Literal, ParamSpec, final
|
||||
|
||||
# Note, all classes "defined" here require special handling.
|
||||
|
||||
@@ -370,7 +370,15 @@ def prepare_class(
|
||||
# Actually a different type, but `property` is special and we want that too.
|
||||
DynamicClassAttribute = property
|
||||
|
||||
def coroutine(func: Callable[..., Any]) -> CoroutineType[Any, Any, Any]: ...
|
||||
_Fn = TypeVar("_Fn", bound=Callable[..., object])
|
||||
_R = TypeVar("_R")
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
|
||||
@overload
|
||||
def coroutine(func: Callable[_P, Generator[_R, Any, Any]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore
|
||||
@overload
|
||||
def coroutine(func: _Fn) -> _Fn: ... # type: ignore
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
CellType = _Cell
|
||||
|
||||
Reference in New Issue
Block a user