Open monosans opened 1 year ago
Unfortunately I think this is a Mypy bug: https://github.com/python/mypy/issues/9031
The object
definition on BaseDeleteView
actually shouldn’t be there, since it comes from DeletionMixin
. If it’s removed, the error occurs without the mixin:
diff --git a/django-stubs/views/generic/edit.pyi b/django-stubs/views/generic/edit.pyi
index 1138df7..7dccd47 100644
--- a/django-stubs/views/generic/edit.pyi
+++ b/django-stubs/views/generic/edit.pyi
@@ -67,7 +67,7 @@ class DeletionMixin(Generic[_M]):
def get_success_url(self) -> str: ...
class BaseDeleteView(Generic[_M, _ModelFormT], DeletionMixin[_M], FormMixin[_ModelFormT], BaseDetailView[_M]):
- object: _M
+ pass
class DeleteView(Generic[_M, _ModelFormT], SingleObjectTemplateResponseMixin, BaseDeleteView[_M, _ModelFormT]):
object: _M
As a workaround, you can redeclare object
in your subclass:
class CategoryDeleteView(DummyMixin, DeleteView[User, ModelForm[User]]):
+ object: User
model = User
Bug report
What's wrong
After updating to version 1.13.0, I'm getting a false positive when using mixins with DeleteView. Probably this commit is related to this bug.
System information
python
version: 3.10.8django
version: 4.1.3mypy
version: 0.982django-stubs
version: 1.13.0django-stubs-ext
version: 0.7.0