'Go to reference' does not traverse through relative imports
See original GitHub issueEnvironment data
- VS Code version: 1.21.p
- Extension version (available under the Extensions sidebar): 2018.2.1
- OS and version: macOS 10.13.3
- Python version (& distribution if applicable, e.g. Anaconda): 3.6.4
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): pipenv with proper python path in vscode
- Relevant/affected Python packages and their versions: flask_restplus
Actual behavior
Going to definition for Namespace from flask_restplus goes to __init__.py
instead of file namespace.py
.
Also vscode shows error “instance of Namespace has no member …” etc, since vscode-python cannot learn that
from .namespace import ...
is
from namespace import ...
Expected behavior
No errors, going to definition is fine
Steps to reproduce:
- Install pipenv, config vscode to work with python version
- Install flask_restplus, import Namespace from library, try to go inside and go to definition of Namespace in init.py file
- See vscode-python does not recognize “from .namespace import” and does not lead anywhere
- Remove dot and repeat
- See everything is working fine now, but source has been modified, so it’s not a solution
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
XXX
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
)
XXX
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
beyond top level package error in relative import
The top-level package is test_A in the error case, and the relative import tries to traverse into the parent package directory, starting at...
Read more >Absolute and Relative Imports in Python - GeeksforGeeks
Relative imports is not so readable as absolute ones. Using relative imports it is not easy because it is very hard to tell...
Read more >Photo by Lacie Slezak on Unsplash - Medium
Module Specifiers rely on a Module Resolution traversing strategy. ... When using Relative Import References, it is also not necessary for ...
Read more >How Pros Get Rid of Relative Imports - DEV Community
Paths · The pathname doesn't have to be the same as the actual folder name. But it's a good idea to keep them...
Read more >The Definitive Guide to Python import Statements | Chris Yeh
The only acceptable syntax for relative imports is from .[module] import name. All import forms not starting with . are interpreted as absolute ......
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
@brettcannon it was my fault actually. I mixed autocompletion with goto definition.
I tried development build and it is indeed fixed! This is fantastic! Thanks!
@idchlife sorry about the misunderstanding! I now understand you wanted to navigate to the module itself and not the object.
But I have good news! Our next release should fix this:
You can download our development build and try it out yourself if you would like to validate we have fixed this.