PyCQA / modernize

Modernizes Python code for eventual Python 3 migration. Built on top of fissix (a fork of lib2to3)
https://modernize.readthedocs.org/
Other
355 stars 51 forks source link

Allow Filter when surrounded by a list #170

Open ihoudjedje opened 6 years ago

ihoudjedje commented 6 years ago

In case having list(filter(None, my_list)) in py2.* , to be able to generate a six compatible python code, the tool transforms the latter to a one-line list comprehension list([_f for _f in my_list if _f]) !!

I understand that the filter function doesn't return a list in py3.* and that we should wrap it in a list in order to have so, but in such situations as the one described above, the filter is already surrounded by list so the code is already a py2&3 compatible and the tool can ignore it.