-
-
Notifications
You must be signed in to change notification settings - Fork 521
Closed
Labels
bugSomething isn't workingSomething isn't workingmypy-pluginIssues specific to mypy_django_pluginIssues specific to mypy_django_plugin
Description
Bug report
The generated through model for many-to-many is not getting typed properly.
What's wrong
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:
- Not sure, but at least
Model PizzaTopping
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.
System information
- OS:
pythonversion: 3.11.1djangoversion: 4.2.2mypyversion: 1.3.0django-stubsversion: 4.2.1
j-osephlong, tony and StabbarN
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmypy-pluginIssues specific to mypy_django_pluginIssues specific to mypy_django_plugin