commands.constant_folding
¶
Module Contents¶
Classes¶
A command that acts identically to a visitor-based transform, but also has |
- class commands.constant_folding.ConvertConstantCommand(context: libcst.codemod.CodemodContext, string: str, constant: str)¶
Bases:
libcst.codemod.VisitorBasedCodemodCommand
A command that acts identically to a visitor-based transform, but also has the support of
add_args()
and running supported helper transforms after execution. SeeCodemodCommand
andContextAwareTransformer
for additional documentation.- DESCRIPTION :str = Converts raw strings to constant accesses.¶
- static add_args(arg_parser: argparse.ArgumentParser) None ¶
Override this to add arguments to the CLI argument parser. These args will show up when the user invokes
libcst.tool codemod
with--help
. They will also be presented to your class’s__init__
method. So, if you define a command with an argument ‘foo’, you should also have a corresponding ‘foo’ positional or keyword argument in your class’s__init__
method.- Parameters
arg_parser (argparse.ArgumentParser) –
- Return type
None
- leave_SimpleString(self, original_node: libcst.SimpleString, updated_node: libcst.SimpleString) Union[libcst.SimpleString, libcst.Name] ¶
- Parameters
original_node (libcst.SimpleString) –
updated_node (libcst.SimpleString) –
- Return type
Union[libcst.SimpleString, libcst.Name]