We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Getting mypy error: project/contact/admin.py:25: error: Signature of "has_add_permission" incompatible with supertype "BaseModelAdmin"
project/contact/admin.py:25: error: Signature of "has_add_permission" incompatible with supertype "BaseModelAdmin"
For example in registering a custom Django Admin such as
class ContactAdmin(admin.ModelAdmin): list_display = ("__str__",) def has_add_permission(self, request: HttpRequest) -> bool: return False admin.site.register(Contact, ContactAdmin)
results in the error above for the method has_add_permission.
has_add_permission
This is possibly due to the fact that
django-stubs/django-stubs/contrib/admin/options.pyi
Line 89 in 8402e7c
has def has_add_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
def has_add_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
while https://github.com/django/django/blob/42b9a23267f14be39b9b00958e18d5746783208e/django/contrib/admin/options.py#L467
has def has_add_permission(self, request):
def has_add_permission(self, request):
i.e obj parameter shouldn't be in stub?
obj
I don't think this error should appear here. The case of has_change_permission for example, works as expected.
has_change_permission
python
django
mypy
django-stubs
The text was updated successfully, but these errors were encountered:
Yes, looks like a bug in stubs. @Sukochev can you please send a PR with the fix?
Sorry, something went wrong.
@sobolevn Sure, will do.
Fix django.contrib.admin.options.BaseModelAdmin.has_add_permission (t…
django.contrib.admin.options.BaseModelAdmin.has_add_permission
2ded7fa
…ypeddjango#203).
Fix django.contrib.admin.options.BaseModelAdmin.has_add_permission (#…
87d59c7
…205) * Fix `django.contrib.admin.options.BaseModelAdmin.has_add_permission` (#203). * Add `django.db.models.base.Model.unique_error_message` (#204).
install dependencies for bump_version workflow (typeddjango#203)
5f94239
Sukochev
Successfully merging a pull request may close this issue.
What's wrong
Getting mypy error:
project/contact/admin.py:25: error: Signature of "has_add_permission" incompatible with supertype "BaseModelAdmin"
For example in registering a custom Django Admin such as
results in the error above for the method
has_add_permission
.This is possibly due to the fact that
django-stubs/django-stubs/contrib/admin/options.pyi
Line 89 in 8402e7c
has
def has_add_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
while https://github.com/django/django/blob/42b9a23267f14be39b9b00958e18d5746783208e/django/contrib/admin/options.py#L467
has
def has_add_permission(self, request):
i.e
obj
parameter shouldn't be in stub?How is that should be
I don't think this error should appear here. The case of
has_change_permission
for example, works as expected.System information
python
version: 3.7.3django
version: 2.2.5mypy
version: 0.720django-stubs
version: 1.1.0The text was updated successfully, but these errors were encountered: