Source code for pydelfini.delfini_core.models.metrics_text

from typing import Any
from typing import Dict
from typing import Type
from typing import TypeVar
from typing import Union

from attrs import define as _attrs_define

from ..types import UNSET
from ..types import Unset


T = TypeVar("T", bound="MetricsText")


[docs] @_attrs_define class MetricsText: """MetricsText model Attributes: avg_length (float): max_length (int): min_length (int): empty_string_count (Union[Unset, int]): Default: 0. """ avg_length: float max_length: int min_length: int empty_string_count: Union[Unset, int] = 0
[docs] def to_dict(self) -> Dict[str, Any]: """Convert to a dict""" avg_length = self.avg_length max_length = self.max_length min_length = self.min_length empty_string_count = self.empty_string_count field_dict: Dict[str, Any] = {} field_dict.update( { "avgLength": avg_length, "maxLength": max_length, "minLength": min_length, } ) if empty_string_count is not UNSET: field_dict["emptyStringCount"] = empty_string_count return field_dict
[docs] @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: """Create an instance of :py:class:`MetricsText` from a dict""" d = src_dict.copy() avg_length = d.pop("avgLength") max_length = d.pop("maxLength") min_length = d.pop("minLength") empty_string_count = d.pop("emptyStringCount", UNSET) metrics_text = cls( avg_length=avg_length, max_length=max_length, min_length=min_length, empty_string_count=empty_string_count, ) return metrics_text