hhatto/autopep8 — pull request #134 by hayd (2014-04-01 02:13:02+00:00)
Title: reindenting with a line range

fixes #133, cc @myint.

Reindent (safely) a line range as much as possible.

It does a quick look behind, and a more complicated look forward around the line range to reindent as best we can *only* within the line range. The general idea is to use the already existing reindent function on blocks which share an indentation level (remove the current indent, apply the reindent function, adds back the indent).

Happy to take comments, add some more test cases, refactor/restyle, or put this behind an option (i.e. make it not the default).

*(Perhaps one approach to increase confidence that this is working correctly is to apply autopep8 with random line ranges to a bad-pep8 python file with high coverage, and check it still passes tests... ?)*