Skip to content

Feature request: Register new operators #16

Description

@Tiago-Lira

Flipper's latest version supports these kind of operators:

  • __gt Greater than
  • __gte Greater than or equal to
  • __lt Less than
  • __lte Less than or equal to
  • __ne Not equals
  • __in Set membership
  • __not_in Set non-membership

However, a complex program may require extra or custom operators. The only way to add new operators are opening a pull-request or doing a hack:

from typing import Iterable

from flipper.conditions.operators.interface import AbstractOperator
from flipper.conditions.operators import Operator


class OverlapOperator(AbstractOperator):
    SYMBOL = "overlap"

    def compare(
        self,
        expected: Iterable,
        actual: Iterable,
    ) -> bool:
        return bool(set(expected) - set(actual)) is False


Operator.OPERATOR_MAP[OverlapOperator.SYMBOL] = OverlapOperator

I'll open a pull-request adding OverlapOperator. But I'd love to hear thoughts about being able to add custom operators for specific projects.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions