Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check correct model on m2m reverse values/values_list #2288

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

flaeppe
Copy link
Member

@flaeppe flaeppe commented Jul 29, 2024

Essentially same as #2283 but now we also include values and values_list.

Related issues

Author().book_set.filter(featured=True)
Author().book_set.filter(xyz=True) # E: Cannot resolve keyword 'xyz' into field. Choices are: authors, featured, id [misc]
reveal_type(Author().book_set.values_list("featured")) # N: Revealed type is "django.db.models.query.QuerySet[myapp.models.Book, Tuple[builtins.bool]]"
Copy link
Member

Choose a reason for hiding this comment

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

Rare case, where Tuple[bool] and not Tuple[bool, ...] is correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah we're fetching a single column so we get a tuple with a single bool

@flaeppe flaeppe merged commit 3a2a9a3 into typeddjango:master Jul 29, 2024
36 checks passed
@flaeppe flaeppe deleted the fix/check-m2m-values-values-list branch July 29, 2024 20:06
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.

2 participants