wrapt icon indicating copy to clipboard operation
wrapt copied to clipboard

Functions with `synchronized` decorator doesn't preserved its typing signature

Open alonp123 opened this issue 2 years ago • 1 comments

I'm using the amazing wrapt.synchronized decorator, but I've just realized that it breaks the typing signature of the wrapped function (using vscode). I tested it with custom wrapt.decorator function and it works fine. Does someone have a solution?

Example:

import wrapt 

@wrapt.decorator
def pass_through(wrapped, instance, args, kwargs):
    return wrapped(*args, **kwargs)

@pass_through
def function(arg):
    print(arg)

@wrapt.synchronized
def synced_function(arg):
    print(arg)

The function signature:

image

The synced_function signature:

image

alonp123 avatar Feb 25 '23 11:02 alonp123

See https://github.com/GrahamDumpleton/wrapt/issues/164 and https://github.com/GrahamDumpleton/wrapt/pull/225. I still haven't got to properly understanding the types annotation mechanism in order to integrate suggested change.

GrahamDumpleton avatar Feb 25 '23 22:02 GrahamDumpleton