Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions stdlib/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ WRAPPER_UPDATES: tuple[Literal["__dict__"]]
class _Wrapped(Generic[_PWrapped, _RWrapped, _PWrapper, _RWapper]):
__wrapped__: Callable[_PWrapped, _RWrapped]
def __call__(self, *args: _PWrapper.args, **kwargs: _PWrapper.kwargs) -> _RWapper: ...
# as with ``Callable``, we'll assume that these attributes exist
__name__: str
__qualname__: str

class _Wrapper(Generic[_PWrapped, _RWrapped]):
def __call__(self, f: Callable[_PWrapper, _RWapper]) -> _Wrapped[_PWrapped, _RWrapped, _PWrapper, _RWapper]: ...
Expand Down
20 changes: 19 additions & 1 deletion test_cases/stdlib/check_functools.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
from __future__ import annotations

import sys
from functools import wraps
from typing import Callable, ParamSpec, TypeVar
Comment thread
AlexWaygood marked this conversation as resolved.
Outdated
from typing_extensions import ParamSpec, assert_type

P = ParamSpec("P")
T_co = TypeVar("T_co", covariant=True)


def my_decorator(func: Callable[P, T_co]) -> Callable[P, T_co]:
func_name = func.__name__

@wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs):
Comment thread
tmke8 marked this conversation as resolved.
Outdated
print(args)
return func(*args, **kwargs)

wrapper.__name__ = func_name
Comment thread
tmke8 marked this conversation as resolved.
Outdated
return wrapper


if sys.version_info >= (3, 8):
from functools import cached_property
from typing_extensions import assert_type

class A:
def __init__(self, x: int):
Expand Down