Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Go to reference is not working for a relative import * #730

Closed
DonJayamanne opened this issue Mar 11, 2019 · 8 comments
Closed

Go to reference is not working for a relative import * #730

DonJayamanne opened this issue Mar 11, 2019 · 8 comments
Assignees
Milestone

Comments

@DonJayamanne
Copy link

@tmab2003 commented on Mon Mar 11 2019

I have the following in my main module: file_1

#file_1.py
from ...scenarios import *
module_1.method_1()

Where I have a module called 'module_1' in the scenarios package which has a method defined 'method_1'

and I cannot seem to F12 in to any of these modules or methods.

@MikhailArkhipov
Copy link

#699

@MikhailArkhipov MikhailArkhipov added this to the March 2019.2 milestone Mar 15, 2019
@MikhailArkhipov
Copy link

@tmab2003 - could you please list structure of your workspace. Is scenarios part of the workspace? Have you tried LS 0.2 from the beta channel?

"python.analysis.downloadChannel": "beta"

@tmab2003
Copy link

@MikhailArkhipov - I added that setting string to the settings.json file for my workspace - will that be adequate?

{ "python.pythonPath": "C:\\Python37\\python.exe", "python.analysis.downloadChannel": "beta" }

The structure is as follows:

../RootFolderForProject/Folder_1/Folder_2/Folder_3/Folder_4/scenarios/module_1.py

file_1 which is here:

../RootFolderForProject/Folder_1/Folder_2/Folder_3/Folder_4/Folder_5/Folder_6/file_1.py

which is why I have to import with three dots, from ...scenarios import * (which should import all modules_*.py)..

@MikhailArkhipov
Copy link

I assume you are opening RootFolderForProject as workspace?
Does the code work in Python console? I am asking since ... does not necessarily mean three folders up per https://www.python.org/dev/peps/pep-0328/ ie "Two or more leading dots give a relative import to the parent(s) of the current package, one level per dot after the first. " .

@tmab2003
Copy link

Yes RootFolderForProject is the workspace folder.

The code works and other Python IDEs seem to navigate this just fine.
In Eclipse (Pydev), I believe I added the workspace directory as a Source Folder (don't remember if this was absolutely necessary for the relative imports to work..)

AlexanderSher added a commit to AlexanderSher/python-language-server that referenced this issue Mar 19, 2019
@tmab2003
Copy link

tmab2003 commented Apr 5, 2019

@AlexanderSher , @MikhailArkhipov - I am not sure if the issue was fixed...but the relative import doesn't seem to be working for relative paths with ... yet. I am on the latest LS as of now.
Microsoft Python Language Server version 0.2.43.0

@jakebailey
Copy link
Member

Are you saying the imports don't work, or go to references? The latter is not in the language server until #819 is merged.

@tmab2003
Copy link

tmab2003 commented Apr 5, 2019

Go to references indeed. Thanks for the update @jakebailey!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants