Closed P1car00n closed 1 year ago
Which version of django
do you have installed? Do you have the django-stubs
library installed? I have the latest version of both installed, and I'm not able to repro the problem you're reporting. My guess is that you have an older version of one or both of these installed. Please upgrade to the latest (pip install django --upgrade
and pip install django-stubs --upgrade
) and see if that fixes your problem.
Thank you for looking into this!
At the time of writing I had django
4.2.5 and didn't use django-stubs
.
I must admit that I'm a bit new to all this; as far as I understand, django-stubs
are used in tandem with mypy
. Instead, I rely on the the Pylance
extension.
Btw, type checking is not the main issue, as since I can't follow the code when I click "Go to Definition", I assume that the problem is more than just something with types, that is, it seems that Pylance doesn't know about StepValueValidator
.
I've created a new venv
for testing, installed all of my dependencies there with mypy
and django-stubs
on top and the Mypy VSCode extension and then set it all up. Result: the issue persisted.
After that I tried importing from django.core.validators import StepValueValidator
on an empty project with only Django installed in the venv
. Result: same, the issue persisted.
The IntelliCode extension doesn't suggest StepValueValidator
either
Can you "Go to Definition" to see StepValueValidator in your VS code?
Can you "Go to Definition" to see StepValueValidator in your VS code?
Yes, I have no problem using "Go To Definition". If I have the django-stubs
installed, it takes me to django-stubs/core/validators.pyi
. If I don't have the django-stubs
installed, it takes me to django/core/validators.py
. In either case, it's able to resolve the imported symbol without a problem.
@debonte or @rchiodo, are you able to repro this with pylance? If you suspect that it's specific to pylance, please transfer the issue.
Pylance currently bundles django-types
instead of django-stubs
. More details here.
The behavior you are seeing is caused by django-types
not containing a stub for StepValueValidator
.
We are aware that the two stubs repos are out of sync and we have recently been discussing doing something different here. That investigation is tracked by an internal issue.
If you copy the contents of django-stubs
into your stubPath
(ex. <workspace-root>/typings/django
) it will take precedence over our bundled copy of django-types
and fix this issue for you.
Bug still in place.
Investigation link broken.
Hi,
Describe the bug With type checking in VS code set to basic:
When importing StepValueValidator in a Django project, Pylance/Pyright doesn't seem to know about it's existence and says: "StepValueValidator" is unknown import symbol Pylance [reportGeneralTypeIssues] (import) StepValueValidator: Unknown
Also, it's impossible to "Go to Definition", which says "No definition found for 'StepValueValidator'"
Importing other validators from django.core.validators and going to their definitions work without a hitch
Code or Screenshots
VS Code extension or command-line I'm running Pylance as a VS Code extension