Closed
Description
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'