diff --git a/tests/typecheck/managers/querysets/test_from_queryset.yml b/tests/typecheck/managers/querysets/test_from_queryset.yml index 59f0cd63c..ec08da3da 100644 --- a/tests/typecheck/managers/querysets/test_from_queryset.yml +++ b/tests/typecheck/managers/querysets/test_from_queryset.yml @@ -675,3 +675,28 @@ ... StrCallable = BaseManager.from_queryset(ModelQuerySet, class_name=str(1)) + +- case: test_queryset_arg_as_unsupported_expressions + main: | + from typing import Union, Generic, TypeVar + from typing_extensions import TypeAlias + from django.db import models + from django.db.models.manager import Manager + + class QS1(models.QuerySet[models.Model]): + ... + class QS2(models.QuerySet[models.Model]): + ... + + Alias: TypeAlias = Union[QS1, QS2] + reveal_type(Manager[models.Model].from_queryset(Alias)) + + T = TypeVar("T") + class NonQSGeneric(Generic[T]): + ... + reveal_type(Manager[models.Model].from_queryset(NonQSGeneric[int])) + out: | + main:12: note: Revealed type is "Type[django.db.models.manager.Manager[django.db.models.base.Model]]" + main:12: error: Argument 1 to "from_queryset" of "BaseManager" has incompatible type ""; expected "Type[_QuerySet[Model, Model]]" [arg-type] + main:17: note: Revealed type is "Type[django.db.models.manager.Manager[django.db.models.base.Model]]" + main:17: error: Argument 1 to "from_queryset" of "BaseManager" has incompatible type "Type[NonQSGeneric[Any]]"; expected "Type[_QuerySet[Model, Model]]" [arg-type]