Skip to content

Base condition

Condition

Bases: ABC

Abstract base class for a condition that can be checked against an event.

check abstractmethod

check(event: Event[V]) -> bool

Check if the condition holds for the given event.

Parameters:

Name Type Description Default
event Event[V]

The event to check.

required

__or__ abstractmethod

__or__(other: Condition) -> Condition

Combine this condition with another condition using OR logic.

Parameters:

Name Type Description Default
other Condition

The other condition.

required

__and__ abstractmethod

__and__(other: Condition) -> Condition

Combine this condition with another condition using AND logic.

Parameters:

Name Type Description Default
other Condition

The other condition.

required

__invert__ abstractmethod

__invert__() -> Condition

Invert this condition (logical NOT).

ConditionOperator

Bases: Enum

Enum representing logical operators for condition combination.

__call__

__call__(*condition: Iterable[Any]) -> bool

Apply the logical operator to the given conditions.

Parameters:

Name Type Description Default
condition Iterable[Any]

The conditions to combine.

()

ConditionExpression

ConditionExpression(*conditions: Condition)

Bases: Condition, ABC

Abstract base class for a composite condition expression.

Parameters:

Name Type Description Default
conditions Condition

The conditions that make up the expression.

()

__invert__ abstractmethod

__invert__() -> Condition

Invert this condition (logical NOT).

Or

Or(*conditions: Condition)

Bases: ConditionExpression

Composite condition representing the logical OR of its conditions.

Parameters:

Name Type Description Default
conditions Condition

The conditions that make up the expression.

()

And

And(*conditions: Condition)

Bases: ConditionExpression

Composite condition representing the logical AND of its conditions.

Parameters:

Name Type Description Default
conditions Condition

The conditions that make up the expression.

()

Neg

Neg(condition: Condition) -> Condition

Create a new condition representing the logical NOT of the given condition.

Parameters:

Name Type Description Default
condition Condition

The condition to invert.

required