Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
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

Description

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.

Activity

  1. MikhailArkhipov commented on Mar 15, 2019

    @MikhailArkhipov
  2. MikhailArkhipov commented on Mar 18, 2019

    @MikhailArkhipov

    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"
  3. tmab2003 commented on Mar 18, 2019

    @tmab2003

    Mikhail Arkhipov (@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)..

  4. MikhailArkhipov commented on Mar 18, 2019

    @MikhailArkhipov

    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. " .

  5. tmab2003 commented on Mar 18, 2019

    @tmab2003

    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..)

  6. added a commit that references this issue on Mar 19, 2019
    4fec936
  7. tmab2003 commented on Apr 5, 2019

    @tmab2003

    Alexander Sher (@AlexanderSher) , Mikhail Arkhipov (@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

  8. jakebailey commented on Apr 5, 2019

    @jakebailey
    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.

  9. tmab2003 commented on Apr 5, 2019

    @tmab2003

    Go to references indeed. Thanks for the update Jake Bailey (@jakebailey)!

  10. added a commit that references this issue on Nov 1, 2019
    0fa0973
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions