We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The generated through model for many-to-many is not getting typed properly.
In the following example:
from typing import reveal_type from django.db import models class Topping(models.Model): label = models.CharField(max_length=100) class Pizza(models.Model): toppings = models.ManyToManyField(Topping) for toppings_through in Pizza.toppings.through.objects.all(): reveal_type(toppings_through) reveal_type(toppings_through.pizza) reveal_type(toppings_through.topping)
I would expect the revealed types to be:
Model
Pizza
Topping
but the result is:
demo.py:14: note: Revealed type is "Any" demo.py:15: note: Revealed type is "Any" demo.py:16: note: Revealed type is "Any"
reveal_type(Pizza.toppings.through) gives Type[django.db.models.base.Model], so I’m assuming that’s where we could be more precise.
reveal_type(Pizza.toppings.through)
Type[django.db.models.base.Model]
python
django
mypy
django-stubs
The text was updated successfully, but these errors were encountered:
ManyToManyField
through
Successfully merging a pull request may close this issue.
Bug report
The generated through model for many-to-many is not getting typed properly.
What's wrong
In the following example:
I would expect the revealed types to be:
Model
Pizza
Topping
but the result is:
reveal_type(Pizza.toppings.through)
givesType[django.db.models.base.Model]
, so I’m assuming that’s where we could be more precise.System information
python
version: 3.11.1django
version: 4.2.2mypy
version: 1.3.0django-stubs
version: 4.2.1The text was updated successfully, but these errors were encountered: