Opened 6 years ago

Last modified 4 years ago

#22712 new Cleanup/optimization

Consider not using built-in functions as parameters

Reported by: Richard Eames Owned by: nobody
Component: contrib.staticfiles Version: 1.6
Severity: Normal Keywords:
Cc: Richard Eames Triage Stage: Accepted
Has patch: no 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 (4)

comment:1 Changed 6 years ago by Tim Graham

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 Changed 6 years ago by Richard Eames

Cc: Richard Eames 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 Changed 6 years ago by Aymeric Augustin

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 Changed 4 years ago by Anton Samarchyan

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top