Skip to content

Preserve row type in merge_annotations_from_custom_method#3383

Merged
sobolevn merged 1 commit into
typeddjango:masterfrom
federicobond:fix-merge-annotations-row-type
May 13, 2026
Merged

Preserve row type in merge_annotations_from_custom_method#3383
sobolevn merged 1 commit into
typeddjango:masterfrom
federicobond:fix-merge-annotations-row-type

Conversation

@federicobond
Copy link
Copy Markdown
Contributor

In the test example, before slicing the queryset type is QuerySet[Foo@AnnotatedWith[...], int] (model arg is the annotated Foo, row arg is int).

The hook ran copy_modified(args=[annotated_type, annotated_type]), which threw away the int and replaced it with the annotated model. With this change, the hook swaps it to the annotated model only if it was previously a model too.

Related issues

Fixes #3381

AI Policy

  • I have read and agree to the AI Policy, removed any "Co-Authored-By" lines attributing coding agents, and manually reviewed the final result

@delfick
Copy link
Copy Markdown
Contributor

delfick commented May 13, 2026

Thanks! I can confirm this removes 72 errors from the django-stubs upgrade for us and we have no more "is not indexable" errors left after this 🥳

Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sobolevn sobolevn merged commit adca4a1 into typeddjango:master May 13, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[6.0.3 regression] Wrong type for slice of annotated values_list query

3 participants