You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wrote a little testcase -- will see if I can figure out a quick fix for it
- case: test_annotate_reverse_relatedmain: | from myapp.models import MB from django.db.models import Count o = MB.objects.annotate(Count("mas")).get() reveal_type(o.mas__count) # N: Revealed type is "builtins.int"installed_apps:
- myappfiles:
- path: myapp/__init__.py
- path: myapp/models.pycontent: | from django.db import models class MA(models.Model): mb = models.ForeignKey("MB", related_name="mas", on_delete=models.CASCADE) class MB(models.Model): pass
What's wrong
_______________________________________ test_annotate_reverse_related _______________________________________
/Users/asottile/workspace/sentry-forked-django-stubs/tests/typecheck/managers/querysets/test_annotate.yml:405:
E pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output:
E Actual:
E main:5: error: "MB" has no attribute "mas__count" [attr-defined] (diff)
E main:5: note: Revealed type is "Any" (diff)
E Expected:
E main:5: note: Revealed type is "builtins.int" (diff)
E Alignment of first line difference:
E E: main:5: note: Revealed type is "builtins.int"
E A: main:5: error: "MB" has no attribute "mas__count" [attr-defined]
E ^
How is that should be
should resolve correctly
System information
OS:
python version: 3.12.6
django version: 5.1.1
mypy version: 1.11.
django-stubs version: 5.1.0
django-stubs-ext version: 5.1.0
The text was updated successfully, but these errors were encountered:
ah I see from reading the code that it just doesn't support non-named arguments. there's a few tests which are passing just due to luck it seems (since they also use non-named arguments assuming they'll produce a WithAnnotations)
what's a little weird is this seems to have worked before django-stubs 5.1.0 -- but I suspect that was due to the old implementation being buggy
Bug report
wrote a little testcase -- will see if I can figure out a quick fix for it
What's wrong
How is that should be
should resolve correctly
System information
python
version: 3.12.6django
version: 5.1.1mypy
version: 1.11.django-stubs
version: 5.1.0django-stubs-ext
version: 5.1.0The text was updated successfully, but these errors were encountered: