-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Summary
from django.db import models
class TestModel(models.Model):
charfield1 = models.CharField(null=True) # Raises DJ001
charfield2: models.CharField[str, str] = models.CharField(null=True) # No error
$ ruff check --select=DJ001 test.py
DJ001 Avoid using `null=True` on string-based fields such as `CharField`
--> test.py:5:18
|
4 | class TestModel(models.Model):
5 | charfield1 = models.CharField(null=True)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 | charfield2: models.CharField[str, str] = models.CharField(null=True)
|
Found 1 error.
I discovered this when using https://github.com/typeddjango/django-stubs with pyright, which doesn't detect the types correctly without explicit annotations.
Version
ruff 0.14.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers