Is it possible to specify type of records in Django QuerySet with Python type hints? Something like QuerySet[SomeModel]?
QuerySet[SomeModel]
For example, we have model:
from typing import (TypeVar, Generic, Iterable, Optional) from django.db.models import Model from django.db.models import QuerySet _T = TypeVar("_T", bound=Model) class QuerySetType(Generic[_T], QuerySet): def __iter__(self) -> Iterable[_T]: pass def first(self) -> Optional[_T]: pass