google / pasta

Library to refactor python code through AST manipulation.
Apache License 2.0
341 stars 40 forks source link

Make pasta indentation easier. #97

Closed martinwicke closed 2 years ago

martinwicke commented 2 years ago

pasta guarantees lossless round-trip but doesn't provide an easy way to change indentation levels. This change adds a special @@indent@@ token which is embedded into the contents of pasta's annotations dict whenever whitespace is detected to be for the purpose of indentation. It is stored instead of the indentation whitespace is represents. If the 'indent' dict entry is changed, the generated code's indentation level will change as a result.