Skip to content

When overriding APIView.get_permissions, mypy complains about return type incompatebility #319

New issue

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

Closed
guldfisk opened this issue Jan 19, 2023 · 0 comments · Fixed by #320
Closed
Labels
bug Something isn't working

Comments

@guldfisk
Copy link
Contributor

In this example:

from rest_framework.viewsets import GenericViewSet
from rest_framework.permissions import BasePermission


class MyView(GenericViewSet):
    def get_permissions(self) -> list[BasePermission]:
        ...

Mypy generates the following error:

example.py:6: error: Return type "List[BasePermission]" of "get_permissions" incompatible with return type "List[_SupportsHasPermission]" in supertype "APIView"  [override]

Even though BasePermission implements _SupportsHasPermission

System information

  • OS:
  • python version: 3.10
  • django version: 4.1
  • mypy version: 0.991
  • django-stubs version: 1.13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
1 participant