Io primitives
io_primitives
Low-level I/O: libcst load/save + git mv with safety guard.
The proto reads with ast (fast, sufficient for analysis) but writes with libcst (preserves quote style, indentation, comments, trailing whitespace — everything ast.unparse silently loses). Migrating mutating helpers to libcst is what gives us back the triple-quoted strings, comments, and blank-line spacing that ast.unparse erases. axm-anvil itself works the same way under the hood.
cst_load(path)
Read path and parse it as a libcst Module. None on parse error.
Source code in packages/axm-audit/src/axm_audit/core/fix/io_primitives.py
cst_save(path, module)
cst_top_level(module)
cst_unwrap(stmt)
Unwrap a SimpleStatementLine to its first small statement, if any.
libcst wraps top-level small statements (imports, assigns) inside
SimpleStatementLine. For comparisons / extraction we usually want
the inner statement (Import, ImportFrom, Assign, …).