Opened 10 years ago

Closed 4 months ago

Last modified 2 months ago

#22712 closed Cleanup/optimization (fixed)

Consider not using built-in functions as parameters

Reported by: no Owned by: Andreu Vallbona
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords:
Cc: no 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 Anton Samarchyan)

Currently the staticfiles finders' find function has a parameter all which is also a built-in function. Personally, I consider using built-ins as parameters/variables to be bad form, and would usually just rename the parameter in my subclasses. Unfortunately, find is explicitly called with all=all in django.contrib.staticfiles.finders.find(). So, to use the built in all() one needs to use from __builtin__ import all as all_.

There are probably more examples throughout the codebase, but this is the one I've run into.

Change History (11)

comment:1 by Tim Graham, 10 years ago

Unfortunately, I think changing this is not going to be worth it, backwards compatibility wise. Will leave it open for a second opinion though.

comment:2 by no, 10 years ago

Cc: no added

Couldn't the arguments undergo the normal django deprecation cycle? For two version accept both, but issue a warning if the builtin version is used.

comment:3 by Aymeric Augustin, 10 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

The all kwarg is a private API, so we can change it. However, we should check whether this is going to break popular third-party addons. (I don't know the staticfiles landscape very well.)

comment:4 by Anton Samarchyan, 8 years ago

Description: modified (diff)

comment:5 by Andreu Vallbona, 5 months ago

Owner: changed from nobody to Andreu Vallbona
Status: newassigned

I think I can work on this ticket. I've created a draft pull request PR Let me know what do you think about it.

comment:6 by Andreu Vallbona, 5 months ago

Has patch: set

comment:7 by Natalia Bidart, 5 months ago

Needs documentation: set
Patch needs improvement: set

comment:8 by Natalia Bidart, 4 months ago

Needs documentation: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin
Version: 1.6dev

comment:9 by nessita <124304+nessita@…>, 4 months ago

Resolution: fixed
Status: assignedclosed

In 0fdcf102:

Fixed #22712 -- Avoided name shadowing of "all" in django.contrib.staticfiles.finders.

Co-authored-by: Natalia <124304+nessita@…>

comment:10 by Natalia Bidart, 4 months ago

In 8719a618:

Refs #22712 -- Corrected deprecation of "all" argument in django.contrib.staticfiles.finders.find().

Features deprecated in Django 5.2 should be removed in Django 6.1.

Last edited 4 months ago by Tim Graham (previous) (diff)

comment:11 by nessita <124304+nessita@…>, 2 months ago

In 6bd5d4f:

Refs #22712 -- Adjusted deprecation warning stacklevel in staticfiles finders.

Note: See TracTickets for help on using tickets.
Back to Top