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

Support "go to definition" for namespace packages #231

Closed
swarnendubiswas opened this issue Nov 15, 2017 · 19 comments
Closed

Support "go to definition" for namespace packages #231

swarnendubiswas opened this issue Nov 15, 2017 · 19 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@swarnendubiswas
Copy link

Environment data

VS Code version: 1.18.0
Python Extension version: 0.8.0
Python Version: 3.5.4
OS and version: CentOS 7.4

Actual behavior

  1. I have run exuberant ctags and have generated tags file in ${workspaceRoot}/.vscode/tags. I have also set "python.autoComplete.extraPaths": [
    "${workspaceRoot}/src"
    ].
  2. Select a function call and press F12, "Go to definition". Visual Studio Code says "No definition found".

Expected behavior

  1. I expect Visual Studio Code to jump to the right tag. "Go to symbol in workspace" is able to find the matching tag.

What is confusing for me is that "go to definition" works for a few method calls, but not for all.

Steps to reproduce:

    1. Select a function call and press F12, "Go to definition". Visual Studio Code says "No definition found".

Logs

Output from Python output panel
No valid output.

Output from Console window (Help->Developer Tools menu)
No valid output.

@DonJayamanne
Copy link

@swarnendubiswas Please could you provide a code sample of a scenario where 'Go to definition' does not work.

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug labels Nov 15, 2017
@swarnendubiswas
Copy link
Author

I understand, but I am referring to a multi-module multi-file project I am working on. I will need to try and create a dummy project to reproduce the problem.

Instead for now, I have attached a screenshot.

screenshot from 2017-11-15 10-38-10

Refer to the static method calls In the screenshot: RunTask.runBench() (line 16) and StatsTask.extractStats() (line 24). VSC is unable to go to definition. It cannot also jump to definition for calls like options.setInputTupleFromStats() (line 38) where options is a object.

However, VSC can jump to definition for util.computeInputsFromStats() where util is the module.

@DonJayamanne
Copy link

I understand, but I am referring to a multi-module multi-file project I am working on

Hmm, thats new information.
Without a proper sample its very difficult to assist. I'll try my best.
When using multi-root workspaces or similar, you'd have problems with paths (we're using Jedi to perform static analysis of the code base to provide intellisense).

Assuming you have the following structure in a multiroot scenario:

  • FolderA
  • FolderB

When using modules from FolderA from code in FolderB, you'd need to modify your PYTHONPATH to help intellisense. One way of doing this is as follows:

  • Create a .env file in your FolderB workspace root
  • Add the following PYTHONPATH=../FolderA (this ensures FolderA will be added into your PYTHONPATH for vscode)
  • Restart VS Code

@swarnendubiswas
Copy link
Author

I have attached a dummy project consisting of a few modules and class definitions. Go to definition does not work for me from the main() function. Please check.
dummy-project.tar.gz

@DonJayamanne DonJayamanne added awaiting 1-verification and removed info-needed Issue requires more information from poster labels Nov 16, 2017
@brettcannon brettcannon changed the title No definition found Support "go to definition" for namespace packages Jan 2, 2018
@brettcannon brettcannon added awaiting 1-decision feature-request Request for new features or functionality and removed awaiting 1-verification area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug labels Jan 2, 2018
@brettcannon
Copy link
Member

brettcannon commented Jan 2, 2018

The problem is all of the packages lack a __init__.py file, so you're relying on namespace packages. That currently isn't supported, so I have turned this into a feature enhancement request.

@scragly
Copy link

scragly commented Feb 5, 2018

This is quite an annoying aspect of VSCode's python extension and is usually seen as a bug by users who come from other editors.

Considering the fact PEP420 has been implemented in Python 3.3 back in 2012, it's not really worth calling this a feature enhancement request. It's simply a total lack of support on a long-incorporated aspect of Python 3; much closer to an actual bug than a lack of some optional feature.

@DonJayamanne
Copy link

@scragly we're sorry about the frustration the lack of this feature may have caused you. However, this is something that was not originally on the list of features to be implemented by the extension, hence this is considered an enhancement to the extension. For instance if Python were to introduce a new feature tomorrow, the lack of support in this extension doesn't mean its a bug, its an area of improvement for the extension. I hope this explains why we're leaving this as an enhancement.

Please note we will be looking into this however the the number of users demanding this feature will most certainly play an important role in the decision making process.

@scragly as a finaly step, please could you 👍 on the top (first) comment so we could keep track of the number of people interested in this issue.

@scragly
Copy link

scragly commented Feb 5, 2018

I already had 👍 the issue when I found it, which is pretty easy to see by hovering over the single 👍that is there.

However you've had multiple issues referenced to this one that have been closed and I suspect those are unlikely contributing to the 'number of users demanding this feature' which is unfortunate.

And even with those in consideration, it's not reflecting the amount of people who use VSCode who either abandon it because they find the autocomplete and Go To Definition nonfunctional in these cases, or simply don't know it's due to it being a native namespace package and instead assume the IDE's intellisense is simply not reliable.

Also python introducing a new feature tomorrow is a bit different from a feature existing since 2012; the expectations from users is simply not comparable between the two situations.

@elliott-beach
Copy link

elliott-beach commented Feb 6, 2018

FYI The Jedi issue for this is davidhalter/jedi#959. (There is also davidhalter/jedi#122 for explicit namespace packages). It would make more sense to patch Jedi than fix it here, probably.

@gustavovalverde
Copy link

gustavovalverde commented Feb 28, 2018

After a bunch of researching, this might be the most killing-feature missing in VS Code for python.

If this also depends on Jedi, the solution might take a while as it comes from 2013 davidhalter/jedi#122

@davidhalter
Copy link

A few days ago I think we fixed the remaining issues. If there are still issues, please post a good test case :)

@DonJayamanne
Copy link

@davidhalter thanks a lot for resolving this issue.

@DonJayamanne
Copy link

Will leave this issue opened, until we've updated VS Code with a version of Jedi that contains the fix.
Unfortunately we cannot release the master branch with VS Code for the next release as we've already updated with VS Code with the latest release of Jedi for our upcoming release of the extension.

@gustavovalverde
Copy link

Thank you very much @davidhalter, just saw your commits sprint with all the fixes.
After VS Code is updated with the latest Jedi I'll be testing. @DonJayamanne, I suppose we could test with the Insider Version of this repo after you do include the Jedi version, so I'll be waiting for that.

@gustavovalverde
Copy link

Just for curiosity, I'll be testing setting "python.jediPath" with a pip install from Jedi master branch.

@davidhalter
Copy link

@DonJayamanne Never use master in a release. I do releases for a reason. I'm just saying test it properly without releasing it :)

@swarnendubiswas
Copy link
Author

swarnendubiswas commented Jun 27, 2018

@brettcannon This is a quite late follow up to your comment about packages not having a __init__.py. However, Go to definition does not work even if I add a __init__.py.

FYI, I can navigate these definitions in Atom.

@shailesh1729
Copy link

shailesh1729 commented Jul 23, 2018

I have +1ed the enhancement request.

I was developing my code in a way that it is split over multiple packages falling in same namespace. The code for individual packages are in totally separate directories. The intellisense feature is not working in this case as of today.

@MikhailArkhipov
Copy link

This was fixed in LS 0.1.72

@lock lock bot locked as resolved and limited conversation to collaborators Jan 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

9 participants