Instagram / Instagram/LibCST

Incorrect expected type for second arg of `deep_replace`

Open
#965 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.9k
Forks
229
PR merge metrics
No merged PRs in 30d

Description

Here is a full repro:

``` python
import libcst as cst

def f(node: cst.Call) -> cst.Call:
arg = node.args[0]
new_arg = arg.with_changes(value=cst.Integer(value="2"))
return node.deep_replace(arg, new_arg)

node = cst.ensure_type(cst.parse_expression("func(1)"), cst.Call)
print(f(node))
```

So we're replacing an `Arg` with an `Arg` in a `Call` node, but type checker complains:
error: Argument 2 to "deep_replace" of "CSTNode" has incompatible type "Arg"; expected "Call" [arg-type]

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.