PyCQA / modernize

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

Request: break out dictionary fixer into multiple fixers #119

Closed rsyring closed 9 years ago

rsyring commented 9 years ago

The dictionary fixer will automatically wrap lots of dictionary iterators with list(...) where it's not really needed, like for loops. This clutters the code and makes the conversion diffs have more "static" IMO.

So, I've been running modernize without libmodernize.fixes.fix_dict_six. Unfortunately, that means I have to manually go through and update things like the conversion of mydict.iteritems() to use the six version.

It would be really helpful IMO to break out the dictionary fixer into one or more fixers so more granularity can be applied when choosing which dictionary fixes someone would want to apply.

takluyver commented 9 years ago

It shouldn't be wrapping things in list() when it's inside a for loop, though I also noticed it doing that recently. I'll see if I can work out what's going on.

takluyver commented 9 years ago

120 should make it smarter about for loops - which isn't quite what you asked for, but it might solve your problem. We could also break them out into multiple fixers.

rsyring commented 9 years ago

IMO #120 is a good solution for this. Thanks.