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

Cannot "Go to Definition" for files in Python Eggs #1685

Closed
choandrew opened this issue Aug 17, 2021 · 12 comments
Closed

Cannot "Go to Definition" for files in Python Eggs #1685

choandrew opened this issue Aug 17, 2021 · 12 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@choandrew
Copy link

Environment data

  • Language Server version: Every version after 2021.5.4; 2021.5.4 and before work correctly
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Miniconda, Python 3.8.2

Expected behaviour

In PyLance 2021.5.4 and before, when I do the command "Go to Definition" (right click on the function and then the first dropdown link), it works as intended and creates a separate tab in VSCode where the highlighted code is defined.

Actual behaviour

When I do the command "Go to Definition" for something like

from InternalPackage.utility.log import Log

where package would be in a Python egg
home/acho/miniconda3/envs/env_name/lib/python3.8/site-packages/internal_package-2.1.2.300-py3.8.egg/InternalPackage/utility/log
I would expect this to work, but instead, PyLance throws "No Definition Found".
PyLance does recognize the correct type for imported classes and signature for functions.

Code Snippet / Additional information

So this works correctly in 2021.5.4 and previous version. However, there was a breaking change made in 2021.6.0

@jakebailey
Copy link
Member

If the file is in an egg, there's no file on disk that VS Code can open, so we don't allow navigation there. Allowing navigation causes VS Code to throw an error that the file isn't found.

I'm not sure how this would have been working on versions that predate egg support; necessarily, if this module is in an egg, and we entirely ignored eggs, we wouldn't have been able to resolve the import. The only way that navigation would have been working is if there was another module of the same name that was being resolved (which would actually be the wrong module, given the egg is resolving it now).

@jakebailey
Copy link
Member

Where does go to def go in the older version? Somewhere else?

@choandrew
Copy link
Author

choandrew commented Aug 17, 2021

the def goes to the correct place in the older versions, ie the 2021.6.0 introduced an update that regressed this functionality for me

So it would be navigating to and opening this file correctly
home/acho/miniconda3/envs/env_name/lib/python3.8/site-packages/internal_package-2.1.2.300-py3.8.egg/InternalPackage/utility/log in the example above

@jakebailey
Copy link
Member

Is that .egg a file, or a folder? I can only think that you can browse to it previously if it's a folder, in which case it's interesting that it's not a file.

@jakebailey jakebailey added the waiting for user response Requires more information from user label Aug 17, 2021
@github-actions github-actions bot removed the triage label Aug 17, 2021
@choandrew
Copy link
Author

choandrew commented Aug 17, 2021

The .egg in the example (home/acho/miniconda3/envs/env_name/lib/python3.8/site-packages/internal_package-2.1.2.300-py3.8.egg/InternalPackage/utility/log) is a folder

the site-packages contains a bunch of folders and files that represent packages (e.g. flake8, pip, wheel, jupyter)
a .egg can be a file or a folder, but in the example above, it is a folder that contains the package contents

@jakebailey
Copy link
Member

I see; I didn't realize that eggs would be folders (not quite sure of the point of them at that point compared to regularly installed modules, but...).

@jakebailey jakebailey added bug Something isn't working needs investigation Could be an issue - needs investigation and removed waiting for user response Requires more information from user labels Aug 19, 2021
@choandrew
Copy link
Author

Eggs being folders is to support Python bindings in C/C++ without compilation, allow for easy import, and allow easy upgrades because it is self-contained

@jakebailey
Copy link
Member

Sure, but one can achieve the same things with packages installed normally in site-packages versus nested in egg folders. (I'm honestly surprised anyone uses eggs these days when wheels have been the standard for a while).

Anyway, it's a bug that we ignore eggs that aren't files.

@choandrew
Copy link
Author

Oh gotcha. Was not aware of wheels vs eggs.
Thank you for the help!

@jakebailey jakebailey added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Aug 24, 2021
@jakebailey
Copy link
Member

This should be fixed in the next release.

@jakebailey
Copy link
Member

We typically leave issues open until the fix is released; reopening.

@jakebailey jakebailey reopened this Aug 25, 2021
@heejaechang
Copy link
Contributor

the fix is in 2021.8.3 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants