question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Go To Definition" not working as expected.

See original GitHub issue

Coming from PyCharm, Go to Defintion is not working as expected. Usually going to package root works - but not functions or constants etc. When it does work it just takes me to __init__.py of the package root.

MacOS 10.14.4 Visual Studio Code 1.34.0 PTVS: 2019.5.18875

FWIW I’m using pipenv.

What am I doing wrong? This is detrimental to productivity.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ericsnowcurrentlycommented, Jun 24, 2019

Thanks for the info, @BeyondEvil. It was super helpful. 😃 At first I had some trouble reproducing the problem you described. After some tweaks I was only able to reproduce some of the issues. Please let us know if you can’t get the results I got, or if I missed anything (i.e. not covered by the 2 issues I opened).

To start off, I did the following:

  1. clone the repo
  2. run python3.7 -m pipenv --python 3.7
  3. run python3.7 -m pipenv install
  4. open the repo’s root directory in VSCode
  5. open e2e/utils/database.py (the extension automatically selected the pipenv virtualenv)
  6. right click on name
  7. click on “Go to Definition”

At that point I was only able to check one of the items (for e2e/utils/database.py) and I didn’t have any problems there.

For the rest I ran into the fact that the “e2e” directory is not on sys.path, so every import of the “api” module was an “unresolved import”. (The extension only adds the project’s root directory to PYTHONPATH.) To work around this I added a top-level .env file with PYTHONPATH=e2e in it.

Below are my final results, post-tweak. For some of the items it worked fine for me. I have opened 2 issues (#6312 and #6314) for the remainder.

Note that all this was using the language server (rather than Jedi). If you are using Jedi (the default), then trying add "python.jediEnabled": false to your settings.json file.


e2e/utils/database.py

** “dadd” (of self.db.dadd(... on line 10) worked with just the initial steps

e2e/tests/conftest.py

  • “api” in from api.base takes me to the definition for api.base; I’ve opened a feature request for what you expected
  • this would require type inference on arbitrary parameters, which we currently do not support; if I explicitly type-annotate the params then “Go to Definition” works; I’ve opened a feature request

e2e/tests/api_tests/test-api.py

  • “api” says “no definition found” (see #6312); “apps”, “fixtures”, and “orgs” all work
  • “orgs” took me to the import (as expected); “Org” worked
  • “get” says “no definition found” (see #6314)

e2e/tests/api/*.py

(assuming you meant e2e/api/orgs.py)

  • same as for e2e/tests/conftest.py
1reaction
BeyondEvilcommented, Jun 10, 2019

@int19h I see! Well, you learn something new every day. 😊

I would really appreciate if you could move the issue to its rightful place.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Go to definition not working as expected when typescript ...
When working in a Typescript or a Javascript project importing this package, if I ⌘+click , I am taken to the type declaration....
Read more >
VS 2019 ignores Go to Definition setting
In Visual Studio 2019, go to View --> Options --> Text Editor --> General · Either uncheck “Enable mouse click to perform Go...
Read more >
Fix: VS Code Go to Definition Not Working - YouTube
Visual Studio Code (VS Code) is a very popular code editor among the developers of the world. This is due to it's awesome...
Read more >
VS Code "go to definition" not working for js files
I am using a repository which has mixed js, jsx, ts, and tsx files. However, the "go to definition" feature is not working...
Read more >
Step 'Go To Definition' not working - shows 'Project ...
When cursor is over a feature file step, pressing 'Go To Definition' results in a message box reading "Project Unavailable". I expected to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found