google / pasta

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

Auto-detect indentation in a file and reuse on unformatted code #68

Closed soupytwist closed 5 years ago

soupytwist commented 5 years ago

Follow-on for #62.

If we insert a node without formatting data into a tree with formatting data, the new node will be printed with default format, including 2 spaces for indentation. If the rest of the file uses tabs or four spaces or whatever, the new code should match this.

The suggestion here is to find the most prevalent indentation style in the file and apply it as the default when indenting unformatted nodes.