Skip to content

Go to definition for Python project does not work with relative imports #274

@imdadahad

Description

@imdadahad

Environment data

VS Code version: Version 1.18.1 (1.18.1)
Python Extension version: 0.8.0
Python Version: 3.6
OS and version: Mac High Sierra

Actual behavior

Assuming my current project structure:

-stopwatch_app
--test.py
--utils
---greeter.py

And contents of:

# test.py

from utils.greeter import print_greeting

def main():
    print_greeting()
# utils/greeter.py

def print_greeting():
   print('Hello')

In test.py, when I select go to definition for the print_greeting method in main (Figure 1), it automatically places the cursor right before the import definition (Figure 2).

Figure 1
image

Figure 2
image

Expected behavior

It should instead take me to the print_greeting() definition in the utils/greeter.py file.

Steps to reproduce:

  • Download the source
    stopwatch_app.zip
  • Open the source project in VSCode
  • Go to test.py, right click on print_greeting() defined in main and select Go To Definition

Logs

Output from Python output panel
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions