-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_signature() for decorated function faulty with manipulated parameter list #1894
Comments
I also noticed that with decorators the Jedi response time for signature requests is terribly slow. I therefore activated debug output and saw that heavy parsing processes are taking place. I also noticed multiple warnings like this:
Unfortunately the response time is also slow when keeping arguments as they are: import functools
def f(x: int, y: float):
pass
def do_wrap2():
@functools.wraps(f)
def wrapper(*args, **kwargs):
return f(*args, **kwargs)
return wrapper
works = do_wrap2()
works( # f(x: int, y: float) For functions without decorators everything is smooth like it should. |
How are you using Jedi? In Interpreter mode? How slow is it in the simple example you gave? 100ms? 1s? 10s? |
I found the time consuming function: project = jedi.Project(path, load_unsafe_extensions=True, sys_path=sys.path)
script = jedi.Script(code, project=project)
sig = script.get_signatures(row, column) # <Signature: index=0 f(*args)>
# The following params call takes ~2.4 seconds
params = sig.params # [<ParamName name='args', description='param *args'>] Please note the returned incorrect signature content. I tested the same example code in our Jedi Interpreter environment. The response is super fast and the returned signature is correct: With the following code the time of import functools
def f(x: int, y: float):
pass
def do_wrap():
@functools.wraps(f)
def wrapper(x: int, y: float):
return f(x, y)
return wrapper
works = do_wrap()
works() # f(x: int, y: float) |
Not sure this is easily fixable without reducing support for a feature... :-/ Definitely also a case of #1059, I'm rewriting Jedi in Rust, where this kind of stuff should not be a problem. But it might take a few years to finish that... |
I can reproduce #1791 with Jedi
0.18.1
and Python3.10.3
using a different approach:So basically the problem occurs when passing different parameters (e.g. different arg object) to
f()
withinwrapper()
. So calling the function like thatf(x, y)
also fails.Motivation: I have a decorator that corrects some args of my wrapped functions (based on different rules) before calling its implementation.
The text was updated successfully, but these errors were encountered: