Instagram / Instagram/LibCST

[FR] Add replaceShallow function to matchers

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

Description

The `matchers` module have functions that operate either just on the given node (`extract`), or in the node and its children (`findall`, `extractall`). However for `replace` there's no such distinction.

One could mimic that behavior by first calling `m.matches(node, matcher)`, but that would be much less performant.

Ideally these two functions would be named `replace` and `replaceall`, to be consistent with the rest of the api, but I do not know what policies you have in place with regards to backwards compatibility.

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.