-
Notifications
You must be signed in to change notification settings - Fork 767
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
How can I make Pylance display the docstring of decorated function not of the decorator? #125
Comments
Thanks for posting the question. Please see this issue for an explanation and a solution. We should consider documenting this, since several users have hit the problem recently. |
Perfect, I was quite confused as of why it was not working. I tried the solution proposed in the issue you mentioned and it works like a charm :) . |
I wonder if there's anything we can do to help detect decorator signatures past documenting the fix with annotations. It seems pretty common to have untyped decorators. (Are the |
If the decorator is completely unannotated and we can't infer any type information (i.e. the return type of the decorator is unknown), Pyright falls back on the assumption that the decorator is leaving the original function unmodified. So that case is handled already. The problem comes from cases where the analyzer is able to infer some type information. The Since |
Hi, |
I've improved the handling of unannotated decorators. The decorated function/method signature and docstring is now retained if the inferred return type of the decorator is a function that accepts only *args or **kwargs (which is the case in the examples above). This change will be in the next release of pylance. |
This issue has been fixed in version 2021.1.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202111-13-january-2021 |
Note that the fix in version 2021.1.1 assumes that the decorator's returned function (aka the |
I cant' seem to be able to obtain the docstring and autocomplete functionality for a decorated function. In fact, as can be seen in the attached images, the docstring and autocomplete are showing the information for the decorator, not the decorated function.
I was wondering if this is the expected behavior, and if it is, how can I get the information for the actual function displayed instead?
For information, if useful, I'm using VS Code1.47.1 for Windows 10, Pylance 2020.7.2, and python 3.7.7 (conda based).
The text was updated successfully, but these errors were encountered: