Code Completion doesn't work for (class) functions decorated with decorators that return inner functions Follow
So, decorated functions break down when when the decorator returns an inner function. This is not necessarily the case for stand-alone functions (unless they return other functions), but class functions show that effect immediately.
As can be seen, I get code completion for this class. But when I try to use code completion for return values, there's nothing:
Even though the viewer does have several functions, none are shown, as the returning type is "Any". If I explicitly name the type for the receiving variable, I have code completion:
So PyCharm does recognize the classes.
At the same time, none of the functions in that package give me parameter hints after I select a function:
As you can see (apart from the wrong documentation style) the function takes a file_name of type str, but the parameter hint only shows *args, **kwargs.
I don't have that problem in VS Code:
This does not happen in PyCharm 2020.2.5 nor in 2020.3
Please sign in to leave a comment.
Update: So PyCharm 2021+ works with decorators, as long as those decorators don't return generic inner functions:
The first decorator prevents parameter hinting (instead you just see P: ParamSpec("P")) and its return type is Any if used on a class function.
The second decorator does not prevent that. The try block is useless, but it's just to show why we need inner functions.
At least some feedback on this issue would be nice. I mean, this bug literally breaks THE key feature of an IDE..code completion.
Apparently code completion is not as important...
Wickermoon could you solve the problem?
One more thing, what are P and R in your first comment?
Still happening for decorators returning `wrapper(*args, **kwargs)`