commands.noop

Module Contents

Classes

NOOPCommand

A Codemod which can be invoked on the command-line

class commands.noop.NOOPCommand(context: libcst.codemod._context.CodemodContext)

Bases: libcst.codemod.CodemodCommand

A Codemod which can be invoked on the command-line using the libcst.tool codemod utility. It behaves like any other codemod in that it can be instantiated and run identically to a Codemod. However, it provides support for providing help text and command-line arguments to libcst.tool codemod as well as facilities for automatically running certain common transforms after executing your transform_module_impl().

The following list of transforms are automatically run at this time:

  • AddImportsVisitor (adds needed imports to a module).

  • RemoveImportsVisitor (removes unreferenced imports from a module).

Parameters

context (libcst.codemod._context.CodemodContext) –

DESCRIPTION :str = Does absolutely nothing.
transform_module_impl(self, tree: libcst.Module) libcst.Module

Override this with your transform. You should take in the tree, optionally mutate it and then return the mutated version. The module reference and all calculated metadata are available for the lifetime of this function.

Parameters

tree (libcst.Module) –

Return type

libcst.Module