Skip to content

Class-based view mixin attributes have incompatible types #152

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
treyhunner opened this issue Sep 3, 2019 · 0 comments · Fixed by #168
Closed

Class-based view mixin attributes have incompatible types #152

treyhunner opened this issue Sep 3, 2019 · 0 comments · Fixed by #168
Labels
bug Something isn't working

Comments

@treyhunner
Copy link

With the following class-based view mixin and a view that inherits from it as well as DetailView, the model and context_object_name attributes are picked up as having incorrect types:

from django.views.generic import DetailView

class ExerciseDetailMixin:
    context_object_name = "exercise"
    model = Exercise

class ExerciseDetailView(ExerciseDetailMixin, DetailView):
    pass
exercises/views.py:95:1: error: Definition of "model" in base class "ExerciseDetailMixin" is incompatible with definition in base class "SingleObjectTemplateResponseMixin"
exercises/views.py:95:1: error: Definition of "model" in base class "ExerciseDetailMixin" is incompatible with definition in base class "SingleObjectMixin"
exercises/views.py:95:1: error: Definition of "context_object_name" in base class "ExerciseDetailMixin" is incompatible with definition in base class "SingleObjectMixin"

Here are their revealed types:

exercises/views.py:100:1: note: Revealed type is 'def (*_args: Any, **_kwds: Any) -> exercises.models.Exercise'
exercises/views.py:101:1: note: Revealed type is 'builtins.str'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants