Skip to content

Go to definition (F12 or Ctrl+LMB) fails when clicking on a relative import #5507

@Trolldemorted

Description

@Trolldemorted

Environment data

  • VS Code version: 1.33.1
  • Extension version (available under the Extensions sidebar): 2019.4.11987
  • OS and version: W10 N Professional 1809 (Build 17763.437)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.3 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): happens with and without virtualenv
  • Relevant/affected Python packages and their versions: All with relative imports

Expected behaviour

Go to definition works

Actual behaviour

Go to definition fails ("No definition found for X"). Additionaly, showing definitions (from type hints) of members of these modules is not reliable.

Steps to reproduce:

  1. execute code . in an empty folder
  2. create a new file (e.g. test.py)
  3. type import requests
  4. put cursor on "requests", press F12, requests' init.py opens as expected
  5. put cursor on .exceptions in the line from .exceptions import RequestsDependencyWarning, press F12

grafik

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
[Info  - 16:59:50] GetCurrentSearchPaths C:\Users\Benni\AppData\Local\Programs\Python\Python37\python.exe 
[Info  - 16:59:50] Python search paths:
[Info  - 16:59:50]     c:\users\benni\appdata\local\programs\python\python37\dlls
[Info  - 16:59:50]     c:\users\benni\appdata\local\programs\python\python37\lib
[Info  - 16:59:50]     c:\users\benni\appdata\local\programs\python\python37
[Info  - 16:59:50]     c:\users\benni\appdata\local\programs\python\python37\lib\site-packages
[Info  - 16:59:50]     c:\users\benni\appdata\local\programs\python\python37\lib\site-packages\enochecker-0.0.1-py3.7.egg
[Info  - 16:59:50]     c:\users\benni\appdata\local\programs\python\python37\lib\site-packages\psutil-5.6.1-py3.7-win-amd64.egg
[Info  - 16:59:50]     c:\users\benni\appdata\local\programs\python\python37\lib\site-packages\elastic_apm-4.2.2-py3.7-win-amd64.egg
[Info  - 16:59:50] Configuration search paths:
[Info  - 17:00:00] Microsoft Python Language Server version 0.2.63.0
[Info  - 17:00:00] Initializing for C:\Users\Benni\AppData\Local\Programs\Python\Python37\python.exe

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

[Extension Host] Python Extension: Cached data exists getEnvironmentVariables, extensions
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, extension-output-#2
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Users\Benni\vscodetest
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, extension-output-#2
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\users\benni\appdata\local\programs\python\python37\lib\site-packages\requests\__init__.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions