Improve [Async]ContextDecorator type hinting (#13416)

Updated annotations allow access to `__wrapped__` on
decorated callables without complaints from typecheckers.
This commit is contained in:
Alyssa Coghlan
2025-01-21 02:58:52 +10:00
committed by GitHub
parent c951dbbc9d
commit 57d7c4334b
2 changed files with 9 additions and 7 deletions

View File

@@ -7,7 +7,6 @@ from re import Pattern
from typing import Any, Literal, TypeVar
from typing_extensions import ParamSpec
_C = TypeVar("_C", bound=Callable[..., Any])
_Func = TypeVar("_Func", bound=Callable[..., Any])
_T = TypeVar("_T")
_P = ParamSpec("_P")
@@ -65,8 +64,7 @@ def decorator(
caller: Callable[..., Any], _func: Callable[..., Any] | None = ...
) -> Callable[[Callable[..., Any]], Callable[..., Any]]: ...
class ContextManager(_GeneratorContextManager[_T]):
def __call__(self, func: _C) -> _C: ...
class ContextManager(_GeneratorContextManager[_T]): ...
def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, ContextManager[_T]]: ...
def append(a: type, vancestors: list[type]) -> None: ...