Transformer (autotransform.transformer.base)

The base class and associated classes for Transformer components.

class autotransform.transformer.base.Transformer

Bases: Generic[TResult], NamedComponent

The base for Transformer components. Transformers are used to execute changes to a codebase. A Transformer takes in a Batch and then executes all changes associated with the Batch.

name

The name of the component.

Type

ClassVar[TransformerName]

name: ClassVar[TransformerName]
abstract transform(batch: Batch) TResult

Execute a transformation against the provided Batch. All writing should be done via CachedFile’s write_content method or FileItem’s write_content method to ensure operations are easily accessible to testing and file content cache’s are kept accurate.

Parameters

batch (Batch) – The Batch that will be transformed.

class autotransform.transformer.base.TransformerName(value)

Bases: str, Enum

A simple enum for mapping.

JSCODESHIFT = 'jscodeshift'
LIBCST = 'libcst'
REGEX = 'regex'
SCRIPT = 'script'