stubber.codemod.modify_list

Module Contents

Classes

ListChangeSet

Describes a set of changes to be made to a list.

ModifyListElements

Modifies the elements of a list (i.e, of modules to stub or exclude),

class stubber.codemod.modify_list.ListChangeSet

Describes a set of changes to be made to a list. - add: a list of elements to add to the list - remove: a list of elements to remove from the list - replace: if True, the list will be replaced with the elements in add

add: Sequence[libcst.BaseExpression]
remove: Sequence[libcst.matchers.BaseMatcherNode]
replace: bool = False
classmethod from_strings(*, add: Sequence[str] | None = None, remove: Sequence[str] | None = None, replace: bool = False) ListChangeSet
Parameters:
  • add (Optional[Sequence[str]]) –

  • remove (Optional[Sequence[str]]) –

  • replace (bool) –

Return type:

ListChangeSet

class stubber.codemod.modify_list.ModifyListElements(*, change_set: ListChangeSet)

Bases: stubber.codemod.utils.ScopeableMatcherTransformer

Modifies the elements of a list (i.e, of modules to stub or exclude), adding and removing elements as specified in the change_set.

Parameters:

change_set (ListChangeSet) –

change_set: ListChangeSet
modify_list_elements(original_node: libcst.List, updated_node: libcst.List) libcst.List
Parameters:
  • original_node (libcst.List) –

  • updated_node (libcst.List) –

Return type:

libcst.List