Re:Show HN: Python Source Code Refactoring Toolkit via AST
by boxed on Monday August 02, 2021 @10:07AM
(#28036681)
You should check out parso which is a fully roundtrip-able AST. That way your tool won't throw away comments and formatting.
[ Parent
| on HN ]
Re:Show HN: Python Source Code Refactoring Toolkit via AST
by treesciencebot on Monday August 02, 2021 @12:18PM
(#28038663)
Thanks for the suggestion though just want to clarify, I am also one of the maintainers of parso :-) (and also the ast module in the standard library)
Re:Show HN: Python Source Code Refactoring Toolkit via AST
by treesciencebot on Monday August 02, 2021 @12:37PM
(#28038982)
Extra clarification: I'm well aware the concerns about tokens vs CST vs AST, that is why I decided to write down a library that does refactors on small code fragments rather than just unparse()ing everything. CST is definitely more sound in terms of preserving these details but dealing with it much more complicated than the regular AST. Refactor's README these also mentions other libraries for complex refactors: parso, LibCST, FixIT