[Django] #34023: ``inlines`` variable not bound in loop in ModelAdmin._create_formsets

6 views
Skip to first unread message

Django

unread,
Sep 19, 2022, 2:11:17 AM9/19/22
to django-...@googlegroups.com
#34023: ``inlines`` variable not bound in loop in ModelAdmin._create_formsets
--------------------------------------------+------------------------
Reporter: Michał Pasternak | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | 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 |
--------------------------------------------+------------------------
Hello,

if you analyze this function with flake8 with bugbear extension:
https://github.com/django/django/blob/cd11664066087051ef11311708ebc55def48d1da/django/contrib/admin/options.py#L2254-L2278

you will get an information about unbound variable ``inlines``, on this
line:
https://github.com/django/django/blob/cd11664066087051ef11311708ebc55def48d1da/django/contrib/admin/options.py#L2265

Not sure how big is the thread, but as inlines is likely a class and
creating code to actually trigger this bug would be a bit complicated,
perhaps it would be useful to just bound the variable in the function
parameters and don't worry about eventual problems in the future?

--
Ticket URL: <https://code.djangoproject.com/ticket/34023>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 19, 2022, 2:12:10 AM9/19/22
to django-...@googlegroups.com
#34023: ``inlines`` variable not bound in loop in ModelAdmin._create_formsets
----------------------------------+--------------------------------------

Reporter: Michał Pasternak | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: dev
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Description changed by Michał Pasternak:

Old description:

> Hello,
>
> if you analyze this function with flake8 with bugbear extension:
> https://github.com/django/django/blob/cd11664066087051ef11311708ebc55def48d1da/django/contrib/admin/options.py#L2254-L2278
>
> you will get an information about unbound variable ``inlines``, on this
> line:
> https://github.com/django/django/blob/cd11664066087051ef11311708ebc55def48d1da/django/contrib/admin/options.py#L2265
>
> Not sure how big is the thread, but as inlines is likely a class and
> creating code to actually trigger this bug would be a bit complicated,
> perhaps it would be useful to just bound the variable in the function
> parameters and don't worry about eventual problems in the future?

New description:

Hello,

you will get an information about unbound variable ``inlines``, on this
line:
https://github.com/django/django/blob/cd11664066087051ef11311708ebc55def48d1da/django/contrib/admin/options.py#L2265

Not sure how big is the thread, but as inlines is likely a class and
creating code to actually trigger this bug would be a bit complicated,

perhaps it would be useful to just bind the variable in the function


parameters and don't worry about eventual problems in the future?

... like:

def user_deleted_form(request, obj, formset, index,
inline=inline):

--

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

Reply all
Reply to author
Forward
0 new messages