from __future__ import annotations

from numbers import Number


def is_number(value: object) -> bool:
    return isinstance(value, Number) and not isinstance(value, bool)



def looks_like_percent(metric_name: str) -> bool:
    normalized = metric_name.lower()
    return (
        "percent" in normalized
        or "coverage" in normalized
        or "ratio" in normalized
        or normalized.endswith("_pct")
        or normalized.endswith("_percent")
    )



def infer_number_format(metric_name: str, explicit_format: str | None = None) -> str | None:
    if explicit_format:
        return explicit_format
    if looks_like_percent(metric_name):
        return "0.00%"
    return None
