Skip to content
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

PyLance using "object()" docs, instead of user-defined #1205

Closed
JulianOrteil opened this issue Apr 29, 2021 · 8 comments
Closed

PyLance using "object()" docs, instead of user-defined #1205

JulianOrteil opened this issue Apr 29, 2021 · 8 comments
Assignees
Labels
bug Something isn't working docstrings fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@JulianOrteil
Copy link

Environment data

  • Language Server version: 2021.4.2
  • OS and version: win32 x64 | Windows 10
  • Python version (and distribution if applicable, e.g. Anaconda): 3.8.8; using Anaconda
  • python.analysis.indexing: undefined
  • python.analysis.typeCheckingMode: off

Expected behaviour

Use the user-defined docs instead of object()'s.

Example
image

Actual behaviour

image

Also very intermittent. Works sometimes, but not always.

Logs

Python Language Server Log

pylancelog.txt

Code Snippet / Additional information

@judej judej added the bug Something isn't working label Apr 29, 2021
@github-actions github-actions bot removed the triage label Apr 29, 2021
@JulianOrteil
Copy link
Author

Checking up on this. Haven't heard back as to whether this is being investigated?

@jakebailey
Copy link
Member

This has to do with the way that we look up docs for init functions. Right now, it appears as though we are looking up the class hierarchy for a doc for __init__, then looking up the class hierarchy for a class doc. With this method, we hit object's __init__ function first.

Changing this so that we walk up the hierarchy once (init then class, repeatedly) would fix this, but cause other issues where the parent class's method doc is what is intended (plus is a little hard to do).

I think that we can probably just omit object's init function doc from our builtin scraped output for now as a workaround, but this does need more testing and speccing (and we have been working on other things, hence the lack of updates; but we do know the root cause).

@JulianOrteil
Copy link
Author

@jakebailey Excellent, thank you for the update.

It's not a major problem, just an annoying persistent one. Let me know if you need anything further from me :)

@RileyMShea
Copy link

@jakebailey I'm currently seeing this on a large subset of classes. I agree I'd much rather be shown no docstring than see the base object string.

One such example is the Timeout class from httpx https://github.com/encode/httpx/blob/b43af721cd7804214396b5511e4f68d144a9b6a6/httpx/_config.py#L190

@jakebailey jakebailey added docstrings needs investigation Could be an issue - needs investigation labels Aug 31, 2021
@jakebailey
Copy link
Member

This is technically a duplicate of #1047, but my plan for this specific issue in the short term is to disable docstring inheritance from the builtins (so no classes get object's docs), as they generally don't appear to be useful (not even the dunder method docs).

@jakebailey jakebailey added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Sep 7, 2021
@jakebailey
Copy link
Member

The next release will include the above change.

@JulianOrteil
Copy link
Author

The next release will include the above change.

Thank you for your work with this, Jake. I appreciate it :)

@jakebailey
Copy link
Member

This issue has been fixed in version 2021.9.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202191-8-september-2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docstrings fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

4 participants