Instagram / LibCST

A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree
https://libcst.readthedocs.io/
Other
1.5k stars 182 forks source link

CSTNode.with_deep_changes type annotation is incomplete #963

Open kit1980 opened 1 year ago

kit1980 commented 1 year ago

For example, I want to replace all args of a Call:

node.with_deep_changes(
    old_node=cst.ensure_type(node.value, cst.Call).args, value=[input_arg]
)

The code works fine, but the type checker complains: error: Argument "old_node" to "with_deep_changes" of "CSTNode" has incompatible type "Sequence[Arg]"; expected "CSTNode"

zsol commented 1 year ago

Last time I checked, it wasn't possible to correctly type annotate this function, unfortunately.

Viicos commented 8 months ago

Might be possible using ParamSpec