I’ve spent the last year building pfst, a library for structural Python source editing.
Why: The standard ast module doesn't preserve anything and LibCST is verbose and you need to know syntax details. I wanted something "Pythonic" where I could treat a tree like a list and have the "formatting math" (commas, indentation, parentheses) handled automatically.
What it does: It allows high-level editing of Python source and AST while handling all the weird syntax nuances (like extra parentheses or complex continuations) without breaking comments or original layout. It's not a formatter, it’s for refactoring and instrumentation (and linting if you really want though LibCST is better for that).
API example of appending a kwarg to all "func()" calls:
for call in module.walk(Call): # module = FST(src)
if call.func.is_Name and call.func.id == 'func':
call.append('correlation_id=CID')
I would love feedback, especially from anyone experienced with existing CST tooling.
tom-pytel•1h ago
Why: The standard ast module doesn't preserve anything and LibCST is verbose and you need to know syntax details. I wanted something "Pythonic" where I could treat a tree like a list and have the "formatting math" (commas, indentation, parentheses) handled automatically.
What it does: It allows high-level editing of Python source and AST while handling all the weird syntax nuances (like extra parentheses or complex continuations) without breaking comments or original layout. It's not a formatter, it’s for refactoring and instrumentation (and linting if you really want though LibCST is better for that).
API example of appending a kwarg to all "func()" calls:
I would love feedback, especially from anyone experienced with existing CST tooling.GitHub: https://github.com/tom-pytel/pfst
PyPI: https://pypi.org/project/pfst/
Documentation: https://tom-pytel.github.io/pfst/