We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For mixin you cannot specify the type of request as it got incompatible with base View
mixin
request
View
from rest_framework import mixins from rest_framework import viewsets from rest_framework.request import Request class MyMixin: request: Request def some_method_with_request_usage(self, *args, **kwargs): print(self.request) class MyViewSet(MyMixin, mixins.ListModelMixin, viewsets.GenericViewSet): pass
The output is:
myfile.py:11: error: Definition of "request" in base class "MyMixin" is incompatible with definition in base class "View" [misc]
As a workaround, you can add the type of the request to the MyViewSet class itself.
MyViewSet
class MyViewSet(MyMixin, mixins.ListModelMixin, viewsets.GenericViewSet): request: Request
But try to imagine that this mixin is used in 100 different places, why we should duplicate the type which should be inferred from the base classes:
Request
P.S. no need to look deeper, inside View
No errors should be reported.
python
django
mypy
django-stubs
The text was updated successfully, but these errors were encountered:
Hi @sobolevn @intgr 👋 Is this bug anywhere on your roadmap? Do you have a suggestion how to approach this issue? Are you willing to accept a PR?
Sorry, something went wrong.
No branches or pull requests
Bug report
For
mixin
you cannot specify the type ofrequest
as it got incompatible with baseView
What's wrong
The output is:
Workaround
As a workaround, you can add the type of the request to the
MyViewSet
class itself.But try to imagine that this mixin is used in 100 different places, why we should duplicate the type which should be inferred from the base classes:
Request
)Request
)P.S. no need to look deeper, inside
View
How is that should be
No errors should be reported.
System information
python
version: 3.9.13django
version: 3.2.13mypy
version: v0.960django-stubs
version: 1.11.0The text was updated successfully, but these errors were encountered: