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
Copy file name to clipboardExpand all lines: tests/typecheck/managers/querysets/test_from_queryset.yml
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -946,3 +946,25 @@
946
946
main:12: error: Argument 1 to "from_queryset" of "BaseManager" has incompatible type "<typing special form>"; expected "Type[QuerySet[Model, Model]]" [arg-type]
947
947
main:17: note: Revealed type is "Type[django.db.models.manager.Manager[django.db.models.base.Model]]"
948
948
main:17: error: Argument 1 to "from_queryset" of "BaseManager" has incompatible type "Type[NonQSGeneric[Any]]"; expected "Type[QuerySet[Model, Model]]" [arg-type]
949
+
950
+
- case: test_reverse_manager_with_foreign_key
951
+
main: |
952
+
from myapp.models import B
953
+
reveal_type(B().a_set.filter(field="something")) # N: Revealed type is "myapp.models.QS"
954
+
installed_apps:
955
+
- myapp
956
+
files:
957
+
- path: myapp/__init__.py
958
+
- path: myapp/models.py
959
+
content: |
960
+
from django.db import models
961
+
962
+
class B(models.Model): ...
963
+
964
+
class QS(models.QuerySet["A"]): ...
965
+
966
+
Manager = models.Manager.from_queryset(QS)
967
+
class A(models.Model):
968
+
field = models.CharField()
969
+
b = models.ForeignKey(B, on_delete=models.CASCADE)
0 commit comments