from typing import Union, Optional

from attrs import field, define
from attrs.validators import instance_of, deep_iterable, optional
from src.data_classes.parameters_visualization import PlotParameters


@define
class CountDistributionPlotParameters(PlotParameters):
    variable: str = field(validator=instance_of(str))
    x_axis_limits: Optional[list[Union[int, float]]] = field(
        default=None,
        validator=optional(
            deep_iterable(
                member_validator=instance_of((int, float)),
                iterable_validator=instance_of(list),
            )
        ),
        kw_only=True,
    )
    x_axis_logarithmic_scaling: bool = field(validator=instance_of(bool))
    y_axis_logarithmic_scaling: bool = field(validator=instance_of(bool))
