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
Go to definition doesn't work on some classes #2460
Using the Go to defintion (F12) feature doesn't always work for me. It depends on which class I'm trying to go to the definition of. I have not been able to determine what the difference is for classes that work versus those that don't. Let me know if you have some suggestions on differences to search for, I'm happy to dig.
In this screenshot, I'm trying to jump to a class called OrderManagerConfiguration. It may be worth noting that Find all references actually works for this class -- it finds about 10 references.
Extension version (available under the Extensions sidebar): 2018.7.1
OS and version: Ubuntu 16.04
Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.3
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
Relevant/affected Python packages and their versions: In-house
Actual behavior
Jump to definition says the class is not found when the class actually exists.
Expected behavior
Jump to definition should jump to the definition of the class.
Steps to reproduce:
Jump to definition does not always fail. I am not able to find the pattern for the failing classes. Please give me your ideas and I can test them on my setup.
Logs
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
Thanks for the detailed report! Is this while using the new Python Language Server? You are using the Python Language Server if the setting for python.jediEnabled is set to false.
Derek Keeler (@d3r3kk) , currently I am not using the Python Language Server. (I did give it a try though, and it has the same behavior -- I get the popup saying "No definition found for class ")
I have learned a bit more about the problem. In my original example, I was trying to jump to a definition of a class called OrderManagerConfiguration, which exists in a module called wa_trading. If I am trying to jump there from another class inside wa_trading, it will find the class and jump to the definition successfully. However, if I try to jump to OrderManagerConfiguration from another module, I get the No definition found error.
Here is a snippit of pip freeze on the modules that I am working in:
Andrew Mittleider (@amittleider) so is the code you are importing in a different folder in your workspace than where you are trying to go to the definition from? And if so how are you making the import work when running your code from VS Code to know where the code happens to be?
I've found that now (since the August update), Go to definition is never working for me in Python code, even when the definition of an item is in the same file. Ex:
def foo():
print('foo!')
def bar():
foo()
Doing a "Go to Definition" on the call to foo() on the final line is giving "No definition found for foo()" See screenshot:
VS Code version: 1.27.1
Extension version (available under the Extensions sidebar): 2018.8.0
OS and version: OSX Sierra (10.12.6)
Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.2
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
And I assume you can execute the above code in your interpreter? (I'm trying to make sure you don't have a broken install because no one else is reporting this level of issue.)
And I can't reproduce with VS Code stable and the latest extension with either Jedi or the language server. Can you paste in what is in the Output panel for Python to see if some obvious error is there?
Squigglies are because I have pydocstyle set up as a linter and there's no docstrings on either method.
As it turns out I need to apologize, as it looks like a restart of VS Code fixed the problem.
What I'm a bit puzzled by is I had the exact same problem a few days ago, and I know I restarted VS Code yesterday for the most recent update. Not sure what changed in that time, but it appears to be working now, apologies for the confusion.
Brett Cannon (@brettcannon) Sorry for the delayed response. To your question about my workspaces, yes, I am trying to jump across workspaces. The reason I need this is complicated, but in short it's because my tests are not discovered by VSCode otherwise.
However, I have done an experiment to see if it's related to my workspaces. I have tried to reduce all my workspaces down to one folder (the parent folder), and I still have the problem. Therefore, I don't strongly suspect it's due to my workspace configuration.
Here are the before and after workspace configurations.
Activity
d3r3kk commentedon Aug 29, 2018
Thanks for the detailed report! Is this while using the new Python Language Server? You are using the Python Language Server if the setting for
python.jediEnabledis set to false.brettcannon commentedon Aug 29, 2018
And just to double-check, this isn't an extension module you're trying to navigate to, correct?
amittleider commentedon Aug 30, 2018
Thanks for the reply.
Derek Keeler (@d3r3kk) , currently I am not using the Python Language Server. (I did give it a try though, and it has the same behavior -- I get the popup saying "No definition found for class ")
Brett Cannon (@brettcannon) I'm not sure what an extension module is. I guess you mean extending with C/C++ code (like this article https://docs.python.org/2/extending/extending.html) ? By this definition, it is not an extension module.
I have learned a bit more about the problem. In my original example, I was trying to jump to a definition of a class called
OrderManagerConfiguration, which exists in a module calledwa_trading. If I am trying to jump there from another class insidewa_trading, it will find the class and jump to the definition successfully. However, if I try to jump toOrderManagerConfigurationfrom another module, I get theNo definition founderror.Here is a snippit of
pip freezeon the modules that I am working in:And here is what my workspace settings look like in VScode:
brettcannon commentedon Sep 6, 2018
Andrew Mittleider (@amittleider) so is the code you are importing in a different folder in your workspace than where you are trying to go to the definition from? And if so how are you making the import work when running your code from VS Code to know where the code happens to be?
pzelnip commentedon Sep 7, 2018
I've found that now (since the August update), Go to definition is never working for me in Python code, even when the definition of an item is in the same file. Ex:
Doing a "Go to Definition" on the call to
foo()on the final line is giving "No definition found for foo()" See screenshot:VS Code version: 1.27.1
Extension version (available under the Extensions sidebar): 2018.8.0
OS and version: OSX Sierra (10.12.6)
Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.2
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
brettcannon commentedon Sep 7, 2018
Why do all of your
deflines have squiggles?And I assume you can execute the above code in your interpreter? (I'm trying to make sure you don't have a broken install because no one else is reporting this level of issue.)
And I can't reproduce with VS Code stable and the latest extension with either Jedi or the language server. Can you paste in what is in the
Outputpanel forPythonto see if some obvious error is there?pzelnip commentedon Sep 7, 2018
Squigglies are because I have pydocstyle set up as a linter and there's no docstrings on either method.
As it turns out I need to apologize, as it looks like a restart of VS Code fixed the problem.
What I'm a bit puzzled by is I had the exact same problem a few days ago, and I know I restarted VS Code yesterday for the most recent update. Not sure what changed in that time, but it appears to be working now, apologies for the confusion.
brettcannon commentedon Sep 10, 2018
We pushed a new version this past Thursday so it's possible you picked that up.
amittleider commentedon Sep 11, 2018
Brett Cannon (@brettcannon) Sorry for the delayed response. To your question about my workspaces, yes, I am trying to jump across workspaces. The reason I need this is complicated, but in short it's because my tests are not discovered by VSCode otherwise.
However, I have done an experiment to see if it's related to my workspaces. I have tried to reduce all my workspaces down to one folder (the parent folder), and I still have the problem. Therefore, I don't strongly suspect it's due to my workspace configuration.
Here are the before and after workspace configurations.
Before:
After: