LibCST icon indicating copy to clipboard operation
LibCST copied to clipboard

Indentation wart when removing an Arg from a Call - is whitespace being represented in the right place?

Open pelson opened this issue 8 months ago • 3 comments

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?

pelson avatar Jun 07 '24 08:06 pelson