Transformer (autotransform.transformer.base)
The base class and associated classes for Transformer components.
- class autotransform.transformer.base.Transformer
Bases:
NamedComponent,Generic[TResult]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]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- 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,EnumA simple enum for mapping.
- AI_MODEL = 'ai_model'
- JSCODESHIFT = 'jscodeshift'
- LIBCST = 'libcst'
- REGEX = 'regex'
- SCRIPT = 'script'
- class autotransform.transformer.base.Transformer
Bases:
NamedComponent,Generic[TResult]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]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- 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.