Closed
Description
Bug report
What's wrong
I have a class inheriting from BaseModelAdmin
and a method delete_model
defined as such:
def delete_model(self, request: HttpRequest, obj: AgendaItem) -> None:
AgendaItem
is a Django model
However, mypy raises an error:
app/chronology/admin.py: note: In member "delete_model" of class "AgendaItemAdmin":
app/chronology/admin.py:376: error: Argument 2 of "delete_model" is
incompatible with supertype "ModelAdmin"; supertype defines the argument type as
"Model" [override]
def delete_model(self, request: HttpRequest, obj: AgendaItem) -> N...
^
because in stubs this function is defined as:
def delete_model(self, request: HttpRequest, obj: Model) -> None: ...
How is that should be
The solution is to make BaseModelAdmin
a generic class with model type variable.
System information
- OS: ArchLinux
python
version: 3.8.6django
version: 3.1.2mypy
version: 0.782django-stubs
version: 1.6.0