You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support "go to definition" for namespace packages #231
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
I have run exuberant ctags and have generated tags file in ${workspaceRoot}/.vscode/tags. I have also set "python.autoComplete.extraPaths": [
"${workspaceRoot}/src"
].
Select a function call and press F12, "Go to definition". Visual Studio Code says "No definition found".
Expected behavior
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:
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.
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.
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.
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)
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
Thank you very much Dave Halter (@davidhalter), just saw your commits sprint with all the fixes.
After VS Code is updated with the latest Jedi I'll be testing. Don Jayamanne (@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.
Brett Cannon (@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.
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.
Activity
DonJayamanne commentedon Nov 15, 2017
Swarnendu Biswas (@swarnendubiswas) Please could you provide a code sample of a scenario where 'Go to definition' does not work.
swarnendubiswas commentedon Nov 15, 2017
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.
Refer to the static method calls In the screenshot:
RunTask.runBench()(line 16) andStatsTask.extractStats()(line 24). VSC is unable to go to definition. It cannot also jump to definition for calls likeoptions.setInputTupleFromStats()(line 38) whereoptionsis a object.However, VSC can jump to definition for
util.computeInputsFromStats()where util is the module.DonJayamanne commentedon Nov 15, 2017
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:
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:
.envfile in your FolderB workspace rootPYTHONPATH=../FolderA(this ensures FolderA will be added into your PYTHONPATH for vscode)swarnendubiswas commentedon Nov 16, 2017
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
[-]No definition found [/-][+]Support "go to definition" for namespace packages[/+]10 remaining items
gustavovalverde commentedon Mar 5, 2018
Thank you very much Dave Halter (@davidhalter), just saw your commits sprint with all the fixes.
After VS Code is updated with the latest Jedi I'll be testing. Don Jayamanne (@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 commentedon Mar 5, 2018
Just for curiosity, I'll be testing setting
"python.jediPath"with a pip install from Jedi master branch.davidhalter commentedon Mar 5, 2018
Don Jayamanne (@DonJayamanne) Never use master in a release. I do releases for a reason. I'm just saying test it properly without releasing it :)
swarnendubiswas commentedon Jun 27, 2018
Brett Cannon (@brettcannon) This is a quite late follow up to your comment about packages not having a
__init__.py. However,Go to definitiondoes not work even if I add a__init__.py.FYI, I can navigate these definitions in Atom.
shailesh1729 commentedon 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 commentedon Dec 17, 2018
This was fixed in LS 0.1.72