python-language-server
python-language-server copied to clipboard
Go to definitions not working in `djangorestframework` or some 3rd party packages
Environment data
- VS Code version: 1.45.0 (should be any though)
- Extension version (available under the Extensions sidebar): 2020.5.78807 (should be any though)
- OS and version: Darwin x64 19.4.0 (should be any though)
- Python version (& distribution if applicable, e.g. Anaconda): 3.6+ (should be any though)
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A, pipenv, poetry
- Relevant/affected Python packages and their versions: djangorestframework==3..10+ (should be any though)
- Relevant/affected Python-related VS Code extensions and their versions: N/A
- Jedi or Language Server? (i.e. what is
"python.jediEnabled"set to; more info microsoft/vscode-python#3977): "python.jediEnabled": false - Value of the
python.languageServersetting: Microsoft
Expected behaviour
can go to definition
Actual behaviour
can NOT go to definition
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
- pip install django djangorestframework
- setup
.vscode/settings.jsonandextensions.json
// settings.json
{
"python.pythonPath": "~/.local/share/virtualenvs/dv-r7UhNc7L/bin/python", // to your python path where djangorestframework lives, to make sure djangorestframework can be referred in python `sys.path`
"python.jediEnabled": false,
"vsintellicode.python.completionsEnabled": true
}
// extensions.json
{
"recommendations": [
"ms-python.python",
"visualstudioexptteam.vscodeintellicode"
]
}
# in any views.py (common django concept)
from rest_framework.viewsets import ModelViewSet
class AnyViewSet(ModelViewSet):
pass
- put the cursor on the word
ModelViewSetand then press F12 (go to definition) - then you will go to
rest_framework/viewsets.py@ModelViewSetdefinition
# rest_framework/viewsets.py
# other code...
class ModelViewSet(mixins.CreateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
mixins.ListModelMixin,
GenericViewSet):
"""
A viewset that provides default `create()`, `retrieve()`, `update()`,
`partial_update()`, `destroy()` and `list()` actions.
"""
pass
# other code...
- put the cursor on the word
mixinsorCreateModelMixinor any super class and then press F12 (go to definition) - you will go no where
- especially
GenericViewSetis right on the same file!
Snapshots


I have the same problem and fixed this by enable python.analysis.memory.keepLibraryAst and python.analysis.memory.keepLibraryLocalVariables in settings.
Yes, those the the settings. By default they are off for memory savings.
@Mozkileo these two settings work like a charm!!!
@MikhailArkhipov I think this should be mentioned somewhere in the doc since some dev like me, prefers debuging while coding