text_lint.operations.assertions.bases.assertion_base.AssertionBase

class text_lint.operations.assertions.bases.assertion_base.AssertionBase(name: str, save: str | None = None, splits: List[Dict[str, Any]] | None = None)[source]

Bases: OperationBase[states.AssertionState], ABC

Assertion operation base class.

class Parameters[source]

Bases: object

Parameter validation for this operation.

__init__(name: str, save: str | None = None, splits: List[Dict[str, Any]] | None = None) None[source]

Initialize AssertionBase instances.

Parameters:
  • name (str) – The name of the configured assertion.

  • save (str | None) – An optional save id to create for matched values.

  • splits (List[Dict[str, Any]] | None) – Optional text splitting configuration for matched values.

Raises:

TypeError

abstract apply(state: states.AssertionState) None[source]

Apply this operation to the given state object.

Parameters:

state (states.AssertionState) – The state object to apply this operation to.

create_result_tree(matches: Sequence[Match[str]]) ResultTree | None[source]

Create a result tree for any matches this assertion generates.

Parameters:

matches (Sequence[Match[str]]) – Regex matches generated by the operation.

Returns:

If applicable the new result tree instance, otherwise None.

Return type:

ResultTree | None

schema_validator(schema_assertion_index: int, schema_assertion_instances: List[AssertionBase], schema_assertion_definitions: List[AliasYamlOperation], schema: Schema) None[source]

Validate this operation in the context of an entire loaded schema.

Parameters:
  • schema_assertion_index (int) – The index of this assertion in the schema.

  • schema_assertion_instances (List[AssertionBase]) – All schema assertion operations.

  • schema_assertion_definitions (List[AliasYamlOperation]) – All schema assertion definitions.

  • schema (Schema) – The active schema instance in use by the linter.

Raises:

TypeError