typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

functools.wraps returns function with incorrect signature

Open Aran-Fey opened this issue 2 years ago • 0 comments

Applying functools.wraps to a function returns the function unchanged, but it should instead copy the signature of the wrapped function:

def func(x: bool) -> str:
    return str(x)

@wraps(func)
def test(*args, **kwargs):
    return func(*args, **kwargs)

print(inspect.signature(test))  # (x: bool) -> str
reveal_type(test)  # Revealed type is "def (*args: Any, **kwargs: Any) -> Any"

Aran-Fey avatar Jul 17 '22 09:07 Aran-Fey