Opened 2 years ago
Last modified 2 years ago
#34023 closed Cleanup/optimization
``inlines`` variable not bound in loop in ModelAdmin._create_formsets — at Version 1
Reported by: | Michał Pasternak | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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 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):