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

Is there a configuration option to enable jumping to builtin module stubs? #317

Closed
bzoracler opened this issue Dec 21, 2022 · 2 comments · Fixed by #321
Closed

Is there a configuration option to enable jumping to builtin module stubs? #317

bzoracler opened this issue Dec 21, 2022 · 2 comments · Fixed by #321
Assignees
Milestone

Comments

@bzoracler
Copy link
Contributor

I'm using Jupyter Lab's Jump to definition, and PR palantir/python-language-server#687 completely disables jumping to 📜extension_module.pyi for the following package arrangement:

📂site-packages
 ┗━📂my_package
   ┣━📜__init__.py
   ┣━📦extension_module.so
   ┗━📜extension_module.pyi

Personally, I also find the behaviour in the PR (disabling jumping to the Python standard library builtins stubs) quite frustrating, as I frequently refer to the Python standard library's stubs.

I've temporarily disabled the behaviour by making the following change,

# pylsp/plugins/definition.py

def _not_internal_definition(definition):
    return True

but am wondering if there's been an update to exposing a configuration for them (preferably accessible in both JupyterLab and VSCode)?

@ccordoba12
Copy link
Member

Hey @bzoracler, thanks for reporting. You said:

but am wondering if there's been an update to exposing a configuration for them (preferably accessible in both JupyterLab and VSCode)?

No, there isn't, sorry. However, you're welcome to add an option for this in a pull request. The plugin already has the follow_imports and follow_builtin_imports options, so I think it shouldn't be hard for you to add one for internal definitions.

@bzoracler
Copy link
Contributor Author

@ccordoba12 After looking at it a bit more and locally reverting the change in palantir/python-language-server#687, I can't reproduce the issue mentioned in that PR on either VSCode or JupyterLab:

If you do Go To Definition (F12 in vscode) on a string, it opens the builtins.pyi file for python 3, because the definition is not being filtered properly.

(Note: I interpreted this to mean, if you try to jump to definition on a string literal, it goes to builtins.pyi::str.)

I understand that VSCode no longer uses python-language-server, but given that Jump to Definition on a string in JupyterLab also doesn't jump to builtins.pyi, would a PR which reverts the changes in palantir/python-language-server#687 be acceptable instead?

I'm happy to add another configuration setting, but I feel like it would be complicating the situation (adding a setting to change a patch which solves a problem that no longer exists). Besides, jumping to stubs if available, even for builtins and extensions, is the default behaviour of both VSCode and other popular IDEs like PyCharm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants