Condition (autotransform.step.condition.base)
The base class and associated classes for Condition components.
- class autotransform.step.condition.base.ComparisonCondition(*, comparison: ComparisonType, value: T = None)
Bases:
Generic
[T
],Condition
The base for comparison Condition components. Uses the ComparisonType enum to perform comparisons.
- comparison
The type of comparison to perform.
- Type
- value
The value to compare against.
- Type
T
- name
The name of the Component.
- Type
ClassVar[ConditionName]
- check(change: Change) bool
Checks whether the Change passes the Condition.
- Parameters
change (Change) – The Change the Condition is checking.
- Returns
Whether the Change passes the condition.
- Return type
bool
- comparison: ComparisonType
- classmethod comparison_type_is_valid(v: ComparisonType) ComparisonType
Validates the condition can perform the specified comparison.
- Parameters
cls (Type[ComparisonCondition]) – The Condition class.
v (ComparisonType) – The comparison to perform.
- Raises
ValueError – Raised if the Condition can not perform the comparison.
- Returns
The unmodified comparison to perform.
- Return type
- abstract get_val_from_change(change: Change) T
Gets the existing value to compare against from the change.
- Parameters
change (Change) – The Change the Condition is checking.
- Returns
The value from the Change to compare against.
- Return type
T
- name: ClassVar[ConditionName]
- static valid_comparisons() Set[ComparisonType]
Gets the valid comparisons that can be done for this condition.
- Returns
The valid comparisons this condition can perform.
- Return type
Set[ComparisonType]
- value: T
- class autotransform.step.condition.base.Condition
Bases:
NamedComponent
The base for Condition components. Used by ConditionalStep to determine whether to take an Action.
- name
The name of the Component.
- Type
ClassVar[ConditionName]
- abstract check(change: Change) bool
Checks whether the Change passes the Condition.
- Parameters
change (Change) – The Change the Condition is checking.
- Returns
Whether the Change passes the condition.
- Return type
bool
- name: ClassVar[ConditionName]
- class autotransform.step.condition.base.ConditionName(value)
Bases:
str
,Enum
A simple enum for mapping.
- AGGREGATE = 'aggregate'
- CHANGE_STATE = 'change_state'
- CREATED_AGO = 'created_ago'
- LABELS = 'labels'
- REVIEWERS = 'reviewers'
- SCHEMA_NAME = 'schema_name'
- TEAM_REVIEWERS = 'team_reviewers'
- UPDATED_AGO = 'updated_ago'
- class autotransform.step.condition.base.ListComparisonCondition(*, comparison: ComparisonType, value: T = None)
Bases:
Generic
[T
],Condition
The base for sortable comparison Condition components. Uses the ComparisonType enum to perform comparisons that are sortable.
- comparison
The type of comparison to perform.
- Type
- value
The value to compare against. Defaults to None.
- Type
optional, Optional[T]
- name
The name of the Component.
- Type
ClassVar[ConditionName]
- check(change: Change) bool
Checks whether the Change passes the Condition.
- Parameters
change (Change) – The Change the Condition is checking.
- Returns
Whether the Change passes the condition.
- Return type
bool
- classmethod check_value_for_comparison(values: Dict[str, Any]) Dict[str, Any]
Ensures that the value is provided for contains/not contains checks or not provided for empty/not empty checks.
- Parameters
cls (Type[ListComparisonCondition]) – The Condition class.
values (Dict[str, Any]) – The values for the comparison.
- Raises
ValueError – Raises errors when values are provided for an empty check or not provided for a contains check.
- Returns
The unmodified values for comparison.
- Return type
Dict[str, Any]
- comparison: ComparisonType
- classmethod comparison_type_is_valid(v: ComparisonType) ComparisonType
Validates the condition can perform the specified comparison.
- Parameters
cls (Type[ListComparisonCondition]) – The Condition class.
v (ComparisonType) – The comparison to perform.
- Raises
ValueError – Raised if the Condition can not perform the comparison.
- Returns
The unmodified comparison to perform.
- Return type
- abstract get_val_from_change(change: Change) List[T]
Gets the existing value to compare against from the change.
- Parameters
change (Change) – The Change the Condition is checking.
- Returns
The value from the Change to compare against.
- Return type
List[T]
- name: ClassVar[ConditionName]
- static valid_comparisons() Set[ComparisonType]
Gets the valid comparisons that can be done for this condition.
- Returns
The valid comparisons this condition can perform.
- Return type
Set[ComparisonType]
- value: Optional[T]
- class autotransform.step.condition.base.SortableComparisonCondition(*, comparison: ComparisonType, value: T = None)
Bases:
ABC
,Generic
[T
],ComparisonCondition
[T
]The base for sortable comparison Condition components. Uses the ComparisonType enum to perform comparisons that are sortable.
- comparison
The type of comparison to perform.
- Type
- value
The value to compare against.
- Type
T
- name
The name of the Component.
- Type
ClassVar[ConditionName]
- static valid_comparisons() Set[ComparisonType]
Gets the valid comparisons that can be done for this condition.
- Returns
The valid comparisons this condition can perform.
- Return type
Set[ComparisonType]