Description
Bug report
What's wrong
On the following code:
from rest_framework import mixins, viewsets
class MyModelListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): ...
I am getting the following error:
error: Missing type parameters for generic type "GenericViewSet" [type-arg]
because I'm not adding a [Type] to GenericViewSet. However, if I do it like so:
from rest_framework import mixins, viewsets
class MyModelListViewSet(mixins.ListModelMixin, viewsets.GenericViewSet[MyModel]): ...
I will get a "not subscriptable" error on execution like so:
TypeError: type 'GenericViewSet' is not subscriptable
How is that should be
The DRF GenericViewSet and its type definition should be compatible. If the viewset is not subscriptable, the stubs should not require a type.
System information
- OS:
python
version: 3.11.11django
version: 5.1.6djangorestframework
version: 3.14.0djangorestframework-stubs
version: 3.14.5mypy
version: 1.11.1django-stubs
version: 4.2.7
Is this a version incompatibility issue? I've tried to see if newer versions of djangorestframework have a subscriptable ViewSet.
Please do let me know what I'm doing wrong and feel free to retag this if needed. Since the GenericViewSet definition has been like this for a long time, I have a feeling I must just be misunderstanding something.