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 definition (F12 or Ctrl+LMB) fails when clicking on a relative import #1022

Description

Benedikt Radtke (@Trolldemorted) commented on Mon Apr 29 2019

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 (View→Output, 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

Activity

  1. added 2 commits that reference this issue on Apr 30, 2019
    a0aaee4
    fb0db70
  2. added 2 commits that reference this issue on Nov 1, 2019
    cc4d82c
    1423a8d
  3. JP01 commented on Jun 4, 2020

    @JP01

    I am still experiencing this issue in 1.45.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions