Open hterik opened 1 week ago
Looks like RawQuerySet
is missing from the monkeypatch list of classes to add __class_getitem__
to:
A PR is welcome for fixing that
As a work-around, you can also use quoted type hints, e.g.
def foo() -> "RawQuerySet[MyModel]":
return MyModel.objects.raw("SELECT id FROM my_model")
or alternatively, add from __future__ import annotations
to the beginning of the file, which causes evaluation of all type hints to be deferred.
Bug report
What's wrong
Using
RawQuerySet
as type annotation is not possible. Without the generic parameter, mypy fails withis not subscriptable
error. With the generic parameter, python throwsTypeError
.System information
python
version: 3.12.3django
version: 5.0.6mypy
version: 1.10django-stubs
version: 5.0.2django-stubs-ext
version: 5.0.2