Open tmozhaev opened 7 months ago
https://github.com/typeddjango/django-stubs/blob/master/django-stubs/db/models/query.pyi#L47
django-stubs
internally uses following typing for concrete models:
_T = TypeVar("_T", bound=Model, covariant=True)
class _QuerySet(Generic[_T, _Row], Collection[_Row], Reversible[_Row], Sized):
model: type[_T]
...
QuerySet: TypeAlias = _QuerySet[_T, _T]
I think TypeVar
and covariant
may be a solution for this issue: just make base class generic and annotate model
attribute the same way.
Solved this in django-admin-smoke:
M = TypeVar("M", models.Model)
class MyTestCase(Generic[M]):
model: Type[M]
It's almost basic functionality of django-stubs :(