#32941: Consider removing unused reverse parameter of
utils.formats.get_format_modules
------------------------------------------------+------------------------
Reporter: Keryn Knight | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Utilities | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Currently the implementation is:
{{{
def get_format_modules(lang=None, reverse=False):
"""Return a list of the format modules found."""
if lang is None:
lang = get_language()
if lang not in _format_modules_cache:
_format_modules_cache[lang] = list(iter_format_modules(lang,
settings.FORMAT_MODULE_PATH))
modules = _format_modules_cache[lang]
if reverse:
return list(reversed(modules))
return modules
}}}
but I'd suggest that removing `reverse` as a parameter should ultimately
have no affect, as it's only used by
`tests.i18n.tests.FormattingTests.test_get_format_modules_stability`
thus the method ''could'' become:
{{{
def get_format_modules(lang=None):
"""Return a list of the format modules found."""
if lang is None:
lang = get_language()
if lang not in _format_modules_cache:
_format_modules_cache[lang] = list(iter_format_modules(lang,
settings.FORMAT_MODULE_PATH))
modules = _format_modules_cache[lang]
return modules
}}}
leaving any downstream caller to do the `reversed(modules)` call
themselves, should they need to. Arguably they might not need/want a list
anyway...
Patch will come to demonstrate that with the adjustment of the single test
everything should be OK to consider removing it. The test would pass
whether or not I reverse the output, but I'm opting to keep intent of the
test method the same...
--
Ticket URL: <https://code.djangoproject.com/ticket/32941>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.eedebe8f93d14407cfd59fdcc332a7a6%40djangoproject.com.