LibCST
LibCST copied to clipboard
Indentation wart when removing an Arg from a Call - is whitespace being represented in the right place?
With the following transformer, and libcst 1.4.0
:
example = """\
foo(
arg1=None,
)
"""
import libcst as cst
class DropArg(cst.CSTTransformer):
def leave_Arg(self, node: cst.Arg, update_node: cst.Arg):
return cst.RemoveFromParent()
result = cst.parse_module(example).visit(DropArg())
print(result.code)
The resulting code looks like:
foo(
)
Is this a symptom of the whitespace/indentation being in the wrong place for Arg objects? Is there a good pattern to remove the whitespace above?