Bug report
Disclaimer: I used AI to help debug this issue.
What's wrong
Updating from 6.0.3 to 6.0.5 led to this new error that is a false positive:
Incompatible type for lookup 'start_date__year__in': (got "list[int]", expected "Iterable[str | date]")
An example line is days_off.filter(start_date__year__in=years) where start_date is a DateField and years which is typed as list[int].
The transform is being ignored, and this seems to have come from #3314.
AI wrote this minimal repro:
from datetime import date
from django.db import models
class Event(models.Model):
start_date = models.DateField()
def by_years(years: list[int]) -> models.QuerySet[Event]:
return Event.objects.filter(start_date__year__in=years) # ← false positive on 6.0.5
def by_year_scalar(year: int) -> models.QuerySet[Event]:
return Event.objects.filter(start_date__year=year) # control: OK
def by_date_in(dates: list[date]) -> models.QuerySet[Event]:
return Event.objects.filter(start_date__in=dates) # control: OK
How is that should be
This should not error.
System information
- OS: MacOS 26.5
python version: 3.14.5
django version: 6.0.5
mypy version: 2.1.0
django-stubs version: 6.0.5
django-stubs-ext version: 6.0.5
Bug report
Disclaimer: I used AI to help debug this issue.
What's wrong
Updating from 6.0.3 to 6.0.5 led to this new error that is a false positive:
Incompatible type for lookup 'start_date__year__in': (got "list[int]", expected "Iterable[str | date]")An example line is
days_off.filter(start_date__year__in=years)wherestart_dateis a DateField andyearswhich is typed aslist[int].The transform is being ignored, and this seems to have come from #3314.
AI wrote this minimal repro:
How is that should be
This should not error.
System information
pythonversion: 3.14.5djangoversion: 6.0.5mypyversion: 2.1.0django-stubsversion: 6.0.5django-stubs-extversion: 6.0.5