Go to definition for Python project does not work with relative imports
See original GitHub issueEnvironment 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
Figure 2
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 onprint_greeting()
defined inmain
and selectGo To Definition
Logs
Output from Python
output panel
N/A
Issue Analytics
- State:
- Created 6 years ago
- Reactions:21
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Go to definition for Python project does not work with relative ...
In test.py , when I select go to definition for the print_greeting method in main (Figure 1), it automatically places the cursor right ......
Read more >Proper relative imports: "Unable to import module"
5 Answers 5 · 1. I have a venv for every project. · I do not use venv. But as per the doco,...
Read more >Absolute vs Relative Imports in Python
A relative import specifies the resource to be imported relative to the current location—that is, the location where the import statement is. There...
Read more >Fix Python Relative Imports and Auto-completion in VSCode
In this video, you will learn how to properly handle Python relative imports without extending the sys.path. Additionally, you will learn ...
Read more >Package Relative Imports - double dot doc example not working
I've been trying to do a double dot import without success, I've tried going back to the official documentation in order to figure...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should be fixed in the next release.
@imdadahad there’s no need to bump the issue as we’ve triaged it and are aware of your request. We just also have 57 other issues to verify along with 41 bugs awaiting fixes. 😟