-
-
Notifications
You must be signed in to change notification settings - Fork 527
Open
Labels
bugSomething isn't workingSomething isn't workingmypy-pluginIssues specific to mypy_django_pluginIssues specific to mypy_django_plugin
Description
Bug report
What's wrong
Types defined using WithAnnotations started failing with mypy 0.981.
from typing import TypedDict
from django.db.models import IntegerField, Model, QuerySet, Value
from django_stubs_ext import WithAnnotations
class Bar(Model):
x = IntegerField()
class BarAnnotations(TypedDict):
y: int
def foo(xyz: QuerySet[Bar]) -> QuerySet[WithAnnotations[Bar, BarAnnotations]]:
return xyz.annotate(y=Value(2))
reveal_type(foo)mypy 0.971:
tmp.py:19: note: Revealed type is "def (xyz: django.db.models.query._QuerySet[tmp.Bar, tmp.Bar]) -> django.db.models.query._QuerySet[django_stubs_ext.WithAnnotations[tmp__Bar, TypedDict('tmp.BarAnnotations', {'y': builtins.int})], django_stubs_ext.WithAnnotations[tmp__Bar, TypedDict('tmp.BarAnnotations', {'y': builtins.int})]]"
Success: no issues found in 1 source file
mypy 0.981/0.982:
tmp.py:16: error: Incompatible return value type (got "_QuerySet[WithAnnotations[tmp__Bar, TypedDict({'y': Any})], WithAnnotations[tmp__Bar, TypedDict({'y': Any})]]", expected "_QuerySet[WithAnnotations[tmp__Bar], WithAnnotations[tmp__Bar]]") [return-value]
tmp.py:19: note: Revealed type is "def (xyz: django.db.models.query._QuerySet[tmp.Bar, tmp.Bar]) -> django.db.models.query._QuerySet[django_stubs_ext.WithAnnotations[tmp__Bar], django_stubs_ext.WithAnnotations[tmp__Bar]]"
Found 1 error in 1 file (checked 1 source file)
It seems mypy infers the return-type of foo as un-annotated, I tried to dig into how the WithAnnotations works but got lost in the plugin quite quickly.
As I'm not sure if this is a mypy or a django-stubs issue, some pointers on where to dig would be welcome.
System information
- OS: macOS 12.6
pythonversion: 3.10.2djangoversion: 4.1.2mypyversion: 0.982django-stubsversion: 1.12.0django-stubs-extversion: 0.5.0
christianbundy, whiskeyriver, sgoodrow-zymergen, gwax, dmartin and 1 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmypy-pluginIssues specific to mypy_django_pluginIssues specific to mypy_django_plugin