from typing import Union
import re
import operator


def condition_matches(value: Union[int, float], format_: str) -> bool:
    """
    Return true if the value matches the condition in the pattern.
    """
    match = re.search(r"\[(>|>=|<|<=|=)(\d*(?:\.\d*)?)\]", format_)
    if not match:
        return True

    operators = {
        ">": operator.gt,
        ">=": operator.ge,
        "<": operator.lt,
        "<=": operator.le,
        "=": operator.eq,
    }
    comparison, threshold = match.groups()
    op = operators[comparison]  # pylint: disable=invalid-name
    return bool(op(float(value), float(threshold)))