[Django] #35564: Improve readability of subclass identification in admin and auth checks

8 views
Skip to first unread message

Django

unread,
Jun 26, 2024, 5:44:00 PM6/26/24
to django-...@googlegroups.com
#35564: Improve readability of subclass identification in admin and auth checks
------------------------------------------------+--------------------------
Reporter: Jaap Roes | Owner: nobody
Type: Cleanup/optimization | Status: assigned
Component: Core (System checks) | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+--------------------------
While researching some code for another ticket I noticed noticed that the
`contrib.admin` and `contrib.auth` `checks` modules have a very similar,
but slightly different, bits of code:

[https://github.com/django/django/blob/e56a32b89bb7fadffdfaa2cdf12b4863ccd5af9b/django/contrib/admin/checks.py#L19-L44
_contains_subclass] and
[https://github.com/django/django/blob/e56a32b89bb7fadffdfaa2cdf12b4863ccd5af9b/django/contrib/auth/checks.py#L12-L25
_subclass_index].

It took some careful reading, but they behave exactly the same, apart from
one returning an index and the other a boolean.

I have a contribution that change these implementations, with the intent
to make it easier to follow the flow.

I tried to find a place in the Django codebase to have a shared
implementation, but I haven't been able to identify one. It would be nice
to have a canonical implementation of these functions.
--
Ticket URL: <https://code.djangoproject.com/ticket/35564>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 26, 2024, 5:51:20 PM6/26/24
to django-...@googlegroups.com
#35564: Improve readability of subclass identification in admin and auth checks
-------------------------------------+-------------------------------------
Reporter: Jaap Roes | Owner: nobody
Type: | Status: assigned
Cleanup/optimization |
Component: Core (System | Version: dev
checks) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jaap Roes):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35564#comment:1>

Django

unread,
Jun 27, 2024, 4:31:36 AM6/27/24
to django-...@googlegroups.com
#35564: Improve readability of subclass identification in admin and auth checks
-------------------------------------+-------------------------------------
Reporter: Jaap Roes | Owner: Jaap Roes
Type: | Status: assigned
Cleanup/optimization |
Component: Core (System | Version: dev
checks) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* owner: nobody => Jaap Roes
* stage: Unreviewed => Accepted

Comment:

Thank you, agree this is nicer 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/35564#comment:2>

Django

unread,
Jun 27, 2024, 4:37:08 AM6/27/24
to django-...@googlegroups.com
#35564: Improve readability of subclass identification in admin and auth checks
-------------------------------------+-------------------------------------
Reporter: Jaap Roes | Owner: Jaap Roes
Type: | Status: assigned
Cleanup/optimization |
Component: Core (System | Version: dev
checks) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35564#comment:3>

Django

unread,
Jun 27, 2024, 7:08:35 AM6/27/24
to django-...@googlegroups.com
#35564: Improve readability of subclass identification in admin and auth checks
-------------------------------------+-------------------------------------
Reporter: Jaap Roes | Owner: Jaap Roes
Type: | Status: closed
Cleanup/optimization |
Component: Core (System | Version: dev
checks) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"f0d05a747f7a099e6c6bc58c42a787546d2212e7" f0d05a74]:
{{{#!CommitTicketReference repository=""
revision="f0d05a747f7a099e6c6bc58c42a787546d2212e7"
Fixed #35564 -- Improved readability of subclass identification.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35564#comment:4>

Django

unread,
Jun 28, 2024, 8:57:51 AM6/28/24
to django-...@googlegroups.com
#35564: Improve readability of subclass identification in admin and auth checks
-------------------------------------+-------------------------------------
Reporter: Jaap Roes | Owner: Jaap Roes
Type: | Status: closed
Cleanup/optimization |
Component: Core (System | Version: dev
checks) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"8cfcf9a30edd3ec0447af6a493b16d21e298e4e0" 8cfcf9a3]:
{{{#!CommitTicketReference repository=""
revision="8cfcf9a30edd3ec0447af6a493b16d21e298e4e0"
Reverted "Fixed #35564 -- Improved readability of subclass
identification."

This reverts commit f0d05a747f7a099e6c6bc58c42a787546d2212e7 due to a
performance regression.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35564#comment:5>
Reply all
Reply to author
Forward
0 new messages