Closed kaplun closed 8 years ago
IMHO it should not be necessary to make list from tuple and set. Can you provide a code snippet where the current code is causing troubles?
It's not really trouble, but more a semantic issue where the name of the function doesn't correspond to its behavior.
In particular, see : https://github.com/inspirehep/inspire-next/pull/1070/files#diff-2dffa3ace57cdc6c5dabaa1d20b1fe6cR87
As reported in https://github.com/inveniosoftware/dojson/pull/155#discussion_r70614422 finally the best solution is just to amend the docstring.
What's the conclusion on this? Do we make a PR to amend the docstring?
In INSPIRE we have implemented a util called force_force_list()
:
https://github.com/inspirehep/inspire-next/blob/master/inspirehep/utils/helpers.py#L68
So IMHO it's OK to go either way.
utils.force_list()
, despite its name and docstring, actually returns atuple
orNone
.A better implementation could be:
however then it would be necessary to amend
filter_values
to also filter away empty lists.