Opened 7 years ago

Closed 7 years ago

#28798 closed Cleanup/optimization (fixed)

Remove unused django.utils.dates.WEEKDAYS_REV, MONTHS_3_REV

Reported by: Chris Lamb Owned by: nobody
Component: Utilities Version: 2.0
Severity: Normal Keywords: dates
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

We have no MONTHS_REV despite having MONTHS whilst we have WEEKDAYS and its reverse WEEKDAYS_REV, as well as MONTHS_3 and MONTHS_3_REV.

Change History (12)

comment:1 by Chris Lamb, 7 years ago

Has patch: set
Needs tests: set

comment:2 by Tim Graham, 7 years ago

Type: UncategorizedCleanup/optimization

MONTHS_3_REV and WEEKDAYS_REV have been in Django since the first commit ("Imported Django from private SVN repository"), but they've never been used. I'd be more inclined to remove them than to add another unused dictionary. Have you found many projects using these dicts?

in reply to:  2 comment:3 by Chris Lamb, 7 years ago

Replying to Tim Graham:

Have you found many projects using these dicts?

I find myself reaching for them fairly often, particulary when making a custom-ish date dropdown or some (admittedly trivial) parsing.

comment:4 by Tim Graham, 7 years ago

I also wonder if these dictionaries merit a continued presence because they are English-centric. I didn't find any usage of them in a GitHub code search.

in reply to:  4 comment:5 by Chris Lamb, 7 years ago

Replying to Tim Graham:

I also wonder if these dictionaries merit a continued presence because they are English-centric. I didn't find any usage of them in a GitHub code search.

That's a fair comment. Shall we just remove the entire file? I'd prefer it "complete" or gone, really :)

comment:6 by Tim Graham, 7 years ago

Only the _REV suffixed dictionaries are unused. My thinking is to remove them. django/utils/dateformat.py uses the other variables.

in reply to:  6 comment:7 by Chris Lamb, 7 years ago

Replying to Tim Graham:

Only the _REV suffixed dictionaries are unused. My thinking is to remove them. django/utils/dateformat.py uses the other variables.

Ahhh, my bad. Well, in that case I'd err in terms of completing it (ie. applying this patch).

comment:8 by Tim Graham, 7 years ago

Usually we've removed things in django.utils once Django no longer uses it. Offhand, I can't think of something in there that Django doesn't use.

comment:9 by Chris Lamb, 7 years ago

Cool, so in summary, we have three paths forward:

a) Remove the unused _REV
b) Complete the set.
c) No action.

You seem to be in favour of "a", I'm leaning towards "b". I'm easy with either - let me know which you would like and I'll go ahead and update the PR/whatever. :)

comment:10 by Claude Paroz, 7 years ago

I'd favour "a", too, unless we find a general-enough use case to demonstrate their utility.

comment:11 by Tim Graham, 7 years ago

Needs tests: unset
Summary: Add a MONTHS_REV dict to match WEEKDAYS/WEEKDAYS_REV & MONTHS_3/MONTHS_3_REVRemove unused django.utils.dates.WEEKDAYS_REV, MONTHS_3_REV
Triage Stage: UnreviewedReady for checkin

comment:12 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 648957b:

Fixed #28798 -- Removed unused django.utils.dates.WEEKDAYS_REV, MONTHS_3_REV.

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