Change (autotransform.change.base)

The base class and associated classes for Change components.

class autotransform.change.base.Change

Bases: NamedComponent

The base for Change components. Used by AutoTransform to manage submissions to code review and source control systems.

name

The name of the Component.

Type:

ClassVar[ChangeName]

abstract abandon() bool

Close out and abandon a Change, removing it from the code review and/or version control system.

Returns:

Whether the abandon was completed successfully.

Return type:

bool

abstract add_labels(labels: List[str]) bool

Adds labels to an outstanding Change.

Parameters:

labels (List[str]) – The labels to add.

Returns:

Whether the labels were added successfully.

Return type:

bool

abstract add_reviewers(reviewers: List[str], team_reviewers: List[str]) bool

Adds reviewers to an outstanding Change.

Parameters:
  • reviewers (List[str]) – The reviewers to add.

  • team_reviewers (List[str]) – Any team reviewers to add.

Returns:

Whether the reviewers were added successfully.

Return type:

bool

abstract comment(body: str) bool

Comments on an outstanding Change.

Parameters:

body (str) – The body of the comment.

Returns:

Whether the comment was successful.

Return type:

bool

abstract get_batch() Batch

Gets the Batch that was used to produce the Change.

Returns:

The Batch used to produce the Change.

Return type:

Batch

abstract get_created_timestamp() int

Returns the timestamp when the Change was created.

Returns:

The timestamp in seconds when the Change was created.

Return type:

int

abstract get_labels() List[str]

Gets all labels for a Change.

Returns:

The list of labels.

Return type:

List[str]

abstract get_last_updated_timestamp() int

Returns the timestamp when the Change was last updated.

Returns:

The timestamp in seconds when the Change was last updated.

Return type:

int

abstract get_mergeable_state() str

Gets the mergeable state of the Change.

Returns:

The mergeable state of the Change.

Return type:

ChangeState

abstract get_review_state() ReviewState

Gets the current review state of the Change.

Returns:

The current review state of the Change.

Return type:

ReviewState

abstract get_reviewers() List[str]

Gets all reviewers for a Change.

Returns:

The list of reviewers.

Return type:

List[str]

abstract get_schema() AutoTransformSchema

Gets the Schema that was used to produce the Change.

Returns:

The Schema used to produce the Change.

Return type:

AutoTransformSchema

get_schema_name() str

Gets the name of the Schema that produced the Change.

Returns:

The name of the Schema.

Return type:

str

abstract get_state() ChangeState

Gets the current state of the Change.

Returns:

The current state of the Change.

Return type:

ChangeState

abstract get_team_reviewers() List[str]

Gets all team reviewers for a Change.

Returns:

The list of team reviewers.

Return type:

List[str]

abstract get_test_state() TestState

Gets the current test state of the Change.

Returns:

The current test state of the Change.

Return type:

TestState

abstract merge() bool

Merges an approved change in to main.

Returns:

Whether the merge was completed successfully.

Return type:

bool

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

name: ClassVar[ChangeName]
abstract remove_label(label: str) bool

Removes a label from an outstanding Change.

Parameters:

label (str) – The label to remove.

Returns:

Whether the label was removed successfully.

Return type:

bool

update(runner: Runner) bool

Update an outstanding Change against the latest state of the codebase.

Parameters:

runner (Runner) – The Runner to use to update the Change.

Returns:

Whether the update was completed successfully.

Return type:

bool

class autotransform.change.base.ChangeName(value)

Bases: str, Enum

A simple enum for mapping.

GITHUB = 'github'
class autotransform.change.base.ChangeState(value)

Bases: str, Enum

A simple enum for the state of a given Change in code review or version control systems.

CLOSED = 'closed'
MERGED = 'merged'
OPEN = 'open'
class autotransform.change.base.ReviewState(value)

Bases: str, Enum

A simple enum for the review state of a given Change in code review or version control systems.

APPROVED = 'approved'
CHANGES_REQUESTED = 'changes_requested'
NEEDS_REVIEW = 'needs_review'
class autotransform.change.base.TestState(value)

Bases: str, Enum

A simple enum for the test state of a given Change in code review or version control systems.

FAILURE = 'failure'
PENDING = 'pending'
SUCCESS = 'success'