-
-
Notifications
You must be signed in to change notification settings - Fork 485
Add InlineModelAdmin.has_add_permission definition #470
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
base: master
Are you sure you want to change the base?
Conversation
Add a proper definition for the InlineModelAdmin's has_add_permission method. Fixes typeddjango#469
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The difference with InlineModelAdmin is that the parent object gets passed in there.
https://github.com/django/django/blob/742d6bc8dbc3868201895933e1c40c36f46462c7/django/contrib/admin/options.py#L2087
https://github.com/django/django/blob/742d6bc8dbc3868201895933e1c40c36f46462c7/django/contrib/admin/options.py#L2170-L2177
Can you rebase it to re-trigger CI?
Looks like this needs to entirely remove the function from Would that sound reasonable? |
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
@blueyed made the change proposed above, still untested (just used GitHub's editor), but I don't think there should be an issue unless Care to re-trigger the workflow? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we can use # type: ignore
on Inline
's version of this method.
I think, that it will be more accurate. In this case, subclasses of BaseModelAdmin
would still have has_add_permission
method.
I haven't checked how inheritance works with |
Mypy copies the method definition from parent. It should be typed as we define it. But, we just silence the error there. |
Add a proper definition for the InlineModelAdmin's has_add_permission method.
Fixes #469
NOTE: This change is entirely untested, so take extra care when reviewing. I'm unsure if the type check works in stub inheritance the same way it does in actual code, but if yes it could be this change will hit the same "incompatible with supertype" error as mentioned in #469