Skip to content

Support "go to definition" for namespace packages #231

Description

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.

Activity

  1. DonJayamanne commented on Nov 15, 2017

    @DonJayamanne

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

  2. added
    info-neededIssue requires more information from poster
    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.
    bugIssue identified by VS Code Team member as probable bug
    on Nov 15, 2017
  3. swarnendubiswas commented on Nov 15, 2017

    @swarnendubiswas
    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.

  4. DonJayamanne commented on Nov 15, 2017

    @DonJayamanne

    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
  5. swarnendubiswas commented on Nov 16, 2017

    @swarnendubiswas
    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

  6. changed the title [-]No definition found [/-] [+]Support "go to definition" for namespace packages[/+] on Jan 2, 2018
  7. 10 remaining items

  8. gustavovalverde commented on Mar 5, 2018

    @gustavovalverde

    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.

  9. gustavovalverde commented on Mar 5, 2018

    @gustavovalverde

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

  10. davidhalter commented on Mar 5, 2018

    @davidhalter

    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 :)

  11. swarnendubiswas commented on Jun 27, 2018

    @swarnendubiswas
    Author

    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.

    FYI, I can navigate these definitions in Atom.

  12. shailesh1729 commented on Jul 23, 2018

    @shailesh1729

    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.

  13. MikhailArkhipov commented on Dec 17, 2018

    @MikhailArkhipov

    This was fixed in LS 0.1.72

  14. locked as resolved and limited conversation to collaborators on Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestRequest for new features or functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions