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

Go to definition does not work for Pandas and other libraries #4972

Closed
nfx opened this issue Feb 27, 2021 · 13 comments
Closed

Go to definition does not work for Pandas and other libraries #4972

nfx opened this issue Feb 27, 2021 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@nfx
Copy link

nfx commented Feb 27, 2021

Issue Type: Bug

Go To Definition does not work for Pandas and any other source type. For example, in this very simple code snippet, i try to CMD+click on a DataFrame symbol and as a seasoned engineer, i expect to go directly to sources of DataFrame class definition, because i have no time to google for documentation nor i generally trust it, because it's either not that extensive or out of date. And sources have more things to show.

import pandas as pd
pd.DataFrame([{'foo': 1, 'bar': 2}])

navigation does not work also for any module in the sys.path:

import os,sys
# (i have all my exploratory notebooks in `notebooks` folder and my other code in packages up the level)
sys.path.append(os.path.abspath('..'))

this does not work for symbols defined in the same notebook as well:

e.g. def foo(): print(1) in one cell, and foo() in the other cell doesn't get me jumping the way i'd expect from an IDE.

Extension version: 2021.3.600686576
VS Code version: Code - Insiders 1.54.0-insider (Universal) (e590188f17162393f50feec19263398e6fe02d13, 2021-02-26T20:39:12.763Z)
OS version: Darwin x64 19.6.0

A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383:30185418
pythonvspyt602:30263608
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30244315
pythonvsdeb440:30224570
pythonvsded773:30223139
pythonvspyt875:30259475
pythonvspyt639:30264824
pythontb:30258533

@nfx
Copy link
Author

nfx commented Feb 27, 2021

Must be part of microsoft/vscode#91987

@joyceerhl
Copy link
Contributor

Thanks, I do repro this behavior. Same behavior in the December release, so we didn't regress this.

Some observations:

  • We do implement provideDefinitions in the notebookConcatMiddleware in the Python extension

  • However ctrl+click does nothing in a notebook

  • Invoking the Go to Definition command from the command palette with a symbol selected results in the following error message:
    image

  • Additionally, when invoking the Go to Definition command, the Jupyter extension's log shows this message:
    Info 2021-02-27 12:43:03: provideCodeActions not currently supported for notebooks

@joyceerhl joyceerhl added bug Issue identified by VS Code Team member as probable bug code-navigation labels Feb 27, 2021
@nfx
Copy link
Author

nfx commented Feb 27, 2021

@joyceerhl my other bug about this was closed with statement it’s working in daily build, but it’s not working, as we see here 😜 I have “all” AB experiments enabled so feel free to add experimental code for more feedback :)

also, it would be great if you can tell me how to get relevant logs for my countless bug reports to make your work easier 😊

@joyceerhl
Copy link
Contributor

Appreciate you taking the time to help us improve our product 😊 To get full logs, add the following setting to your user settings.json:

"jupyter.logging.level": "debug"

Then reload VSCode for the new setting to take effect, and you'll be able to find debug logs in the Jupyter output tab:
image

@nfx
Copy link
Author

nfx commented Feb 28, 2021

@joyceerhl where settings.json is located on macOS? Is it project level or user level?

@joyceerhl
Copy link
Contributor

@nfx that would be user level. You can find it by running Cmd+Shift+P to bring up the command palette, then typing in 'Open Settings (JSON)' and selecting the top option.

@IanMatthewHuff IanMatthewHuff self-assigned this Mar 8, 2021
@IanMatthewHuff
Copy link
Member

I poked at this a bit on current VS Code - Insiders. I do see an initial failure the first time that I do Go To Definition or use F12. But then after that initial failure it seem to work correctly for me, but only for a basic intra file example (def foo in one call, foo() in another). Not getting any success on the example of pandas dataframe while it works just fine in .py. Looking more now.

@nfx
Copy link
Author

nfx commented Mar 11, 2021

@IanMatthewHuff i think pandas example doesn't work because symbols, it's not defined in the workspace, but it is a dependency. And indexing/debugging non-workspace symbols is disabled by default, as far as i understood. i think we really need a popup window asking to enable this. Anyway, my expectation from IDE is to look for symbol in every submodule defined in sys.path.

@IanMatthewHuff
Copy link
Member

@nfx. While digging in on this I found a straight up bug here. Basically outgoing links (goto def and whatnot) from inside a notebook file to anything outside a notebook file were not working. I have a fix in progress and should hit the insiders build of the Python extension soonish. Just follow this issue and you should see when it gets closed.

@IanMatthewHuff
Copy link
Member

Note for team validation. This was resolved in the Python extension.

@joyceerhl
Copy link
Contributor

Validated against latest main for Python + Jupyter extension.

@nfx
Copy link
Author

nfx commented Apr 3, 2021

yes! it works! thanks!

@IanMatthewHuff
Copy link
Member

@nfx Awesome. Thanks for the confirmation.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants