Skip to content

Wrong typing for grouping .values() in 6.0.7 #3509

Description

@fmorenodesigns

Bug report

What's wrong

In version 6.0.7, using .values() to group the queryset, makes the type-checker ignore any following annotated values. For example, in:

variable = Foo.objects.filter(foo=2).values("bar").annotate(_annotated_value=Value(3))

mypy thinks that variable is a dict with a single key "bar", but that's not true.

How is that should be

"_annotated_value" is also part of the type.

System information

  • OS: macOS 26.5
  • python version: 3.14.6
  • django version: 5.2.16
  • mypy version: 2.3.0
  • django-stubs version: 6.0.7
  • django-stubs-ext version: 6.0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions