Index
_cst
Private CST primitives shared by move/rename/split tooling.
This sub-package is intentionally internal: symbols here are subject to
change without notice. External consumers should use the public
axm_anvil API instead.
Block
dataclass
A top-level symbol definition extracted from a module.
Carries the CST statement that defines the symbol, the leading
formatting lines that immediately precede it (used to preserve
# --- Section --- comments), and the set of external names
referenced by its body.
Source code in packages/axm-anvil/src/axm_anvil/_cst/blocks.py
ReferenceCollector
Bases: CSTVisitor
Collect referenced names within a CST node.
Visits all Name occurrences and records only the root of any
Attribute chain (foo.bar.baz -> "foo").
Source code in packages/axm-anvil/src/axm_anvil/_cst/visitors.py
visit_Attribute(node)
Record only the root of an Attribute chain; skip nested visit.
Source code in packages/axm-anvil/src/axm_anvil/_cst/visitors.py
RemoveSymbols
Bases: _DepthTracker
Remove targeted top-level ClassDef, FunctionDef, or constant
assignments (Assign / AnnAssign) from a module.
Surrounding formatting (comments, blank lines, indentation of other
top-level symbols) is preserved thanks to libcst's lossless tree.
Non-assignment SimpleStatementLine nodes (imports, docstrings,
bare expressions) are left untouched.
Source code in packages/axm-anvil/src/axm_anvil/_cst/transformers.py
leave_ClassDef(original_node, updated_node)
Drop the class when its top-level name matches a removal target.
Source code in packages/axm-anvil/src/axm_anvil/_cst/transformers.py
leave_FunctionDef(original_node, updated_node)
Drop the function when its top-level name matches a removal target.
Source code in packages/axm-anvil/src/axm_anvil/_cst/transformers.py
leave_SimpleStatementLine(original_node, updated_node)
Drop top-level statement lines whose assignments target a removed name.
Source code in packages/axm-anvil/src/axm_anvil/_cst/transformers.py
detect_overload_group(tree, symbol_name)
Return the ordered overload group for symbol_name.
Includes every top-level FunctionDef with that name when at
least one is decorated with @overload (or @typing.overload
or a resolved alias). Returns [] otherwise.
Source code in packages/axm-anvil/src/axm_anvil/_cst/overloads.py
dotted_name(node)
Convert a Name / Attribute chain to its dotted string form.
Returns an empty string for any other node type.
Source code in packages/axm-anvil/src/axm_anvil/_cst/visitors.py
extract_blocks(tree, symbol_names)
Extract Block records for each requested top-level symbol.
Supports ClassDef, FunctionDef, Assign, and AnnAssign
at module scope. Missing symbols are silently omitted.