-
-
Notifications
You must be signed in to change notification settings - Fork 485
admin.TabularInline: Signature of "has_add_permission" incompatible with supertype "BaseModelAdmin" #469
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
Comments
Loosely related to #203 |
@JoaRiski PRs are appreciated! |
Add a proper definition for the InlineModelAdmin's has_add_permission method. Fixes typeddjango#469
Improve how `has_add_permission` is declared by removing it from `BaseModelAdmin` and adding it directly to `ModelAdmin`. This is required as `InlineModelAdmin` has a different signature, see typeddjango#469
I think the types are wrong in addition to this. If we look at the Django docs https://docs.djangoproject.com/en/4.0/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin.has_add_permission the inlines are defined as being passed the parent object, not the current object, but the types generated by django-stubs complain if I don't specify the type as e.g.
If I change parent to ScheduledChangeLog, which it should be, I get:
The same applies to |
Uh oh!
There was an error while loading. Please reload this page.
What's wrong
The signature for the
admin.TabularInline.has_add_permission
method seems to be wrongly typed, resulting in the following error when a subclass declares a type according to the Django documentation:Example signature resulting in this error:
The problem seems to be caused by the TabluarInline directly inheriting the types from here
django-stubs/django-stubs/contrib/admin/options.pyi
Line 109 in 19c73a1
When in reality the InlineModelAdmin has a different signature for the
has_add_permission
function:https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin.has_add_permission
How is that should be
The
has_add_permission
should be typed specifically for theInlineModelAdmin
class rather than inheriting fromBaseModelAdmin
.It would be a good idea to verify other
has_x_permission
methods at the same time, as the inline admin functions might differ from the base model adminSystem information
python
version: 3.8.5django
version: 3.1.1mypy
version: 0.770django-stubs
version: 1.5.0The text was updated successfully, but these errors were encountered: