Instagram / Instagram/LibCST

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

Open
#1,157 3 comments 0 reactions 0 assignees View on GitHub
enhancement parsing
Dominant language
Python
Stars
1.9k
Forks
229
PR merge metrics
No merged PRs in 30d

Description

With the following transformer, and libcst `1.4.0`:

```python
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:

```python
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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.