Open
Description
Bug report
What's wrong
After upgrading to django-stubs
version > 5.1.1, VSCode's type intelligence no longer correctly infers the type of model fields. Specifically, it treats fields as Any
instead of their expected types.
Reproduction
Minimal example:
from django.db import models
class Temp(models.Model):
text = models.TextField()
t = Temp()
t.text # Expected: str, but reported as Any in VSCode
Expected Behavior
- django-stubs 5.1.1 correctly infers t.text as str in VSCode.
- django-stubs > 5.1.1 incorrectly treats t.text as Any in VSCode.
Observations
- Running mypy still shows str as expected.
- Issue only affects VSCode’s type intelligence (Pylance/pyright).
- Removing the py.typed file from the django-stubs folder fixes the issue, but the reason is unclear.
- Downgrading django-stubs to 5.1.1 restores correct type inference.
How is that should be
VSCode should correctly infer the type of model fields, just like in django-stubs 5.1.1. The expected behavior is:
t.text # Type should be inferred as str, not Any
System information
- OS: Mac
python
version: 3.11django
version: 5.1mypy
version: 1.13.0django-stubs
version: 5.1.3django-stubs-ext
version: 5.1.3