pylance-release
pylance-release copied to clipboard
Installed stubs don't take precedence over bundled stubs
See this issue #5027
- Install django-stubs into your environment
- Set typechecking mode to basic
- Add the following code to a file
from django.db import models
class MyModel(models.Model):
nullable = models.IntegerField(null=True)
def foo():
m = MyModel.objects.get()
def accepts_only_int(x: int):
pass
accepts_only_int(m.nullable)
- If we actually used the django-stubs, passing m.nullable to accepts_only_int shouldn't show an error.
- If you goto declaration on models.IntegerField it will still jump into our bundled stubs.
I am seeing the same behaviour:
Tested in v2023.20.0 and v2023.21.13141007 and in both cases Pylance is choosing the bundled stubs over the installed ones.
It's a very annoying workaround, but what I'm doing in a devcontainer is as follows:
rm -rf ~/.vscode-server/extensions/ms-python.vscode-pylance-2023.12.1/dist/bundled/stubs/django-stubs
Then reloading the window causes Pylance to find the real django-stubs that were installed. There should be an option to disable the extension's bundled stubs.