<commit_before>from pydantic import BaseModel, constr, Field, validator
from virtool_core.models.label import Label

from virtool_core.models import normalize_hex_color


class CreateLabelSchema(BaseModel):
    """
    Label fields for creating a new label.
    """

    name: constr(strip_whitespace=True, min_length=1) = Field(
        description="unique name for the label document"
    )
    color: constr(strip_whitespace=True) = Field(default="#A0AEC0", description="color of the label")
    description: constr(strip_whitespace=True) = Field(
        default="", description="description of the document"
    )

    _ensure_color_is_normalized: classmethod = validator("color", allow_reuse=True)(
        normalize_hex_color
    )

    class Config:
        schema_extra = {
            "example": {
                "color": "#374151",
                "description": "dsRNA/binding protein",
                "name": "Binding protein"
            }
        }


class CreateLabelResponse(Label):
    class Config:
        schema_extra = {
            "example": {
                "color": "#374151",
                "count": 0,
                "description": "dsRNA/binding protein",
                "id": 23,
                "name": "Binding protein"
            }
        }


class EditLabelSchema(BaseModel):
    """
    Label fields for editing an existing label.
    """

    name: constr(strip_whitespace=True) = Field(
        description="name of the existing label document"
    )
    color: constr(strip_whitespace=True)
    description: constr(strip_whitespace=True) = Field(
        description="description of the existing label document"
    )

    _ensure_color_is_normalized: classmethod = validator("color", allow_reuse=True)(
        normalize_hex_color
    )

    class Config:
        schema_extra = {
            "example": {
                "color": "#93C5FD",
                "description": "Blueberry",
                "name": "Blueberry"
            }
        }


class LabelResponse(Label):
    class Config:
        schema_extra = {
            "example": {
                "color": "#6B7280",
                "count": 0,
                "description": "dsRNA/Ab",
                "id": 22,
                "name": "Ab"
            }
        }


class GetLabelResponse(Label):
    class Config:
        schema_extra = {
            "example": [
                {
                    "color": "#6B7280",
                    "count": 0,
                    "description": "dsRNA/Ab",
                    "id": 22,
                    "name": "Ab"
                }
            ]
        }<commit_msg>fix: prevent import-related error on start<commit_after>from pydantic import BaseModel, constr, Field, validator
from virtool_core.models import normalize_hex_color
from virtool_core.models.label import Label


class CreateLabelSchema(BaseModel):
    """
    Label fields for creating a new label.
    """

    name: constr(strip_whitespace=True, min_length=1) = Field(
        description="unique name for the label document"
    )
    color: constr(strip_whitespace=True) = Field(
        default="#A0AEC0", description="color of the label"
    )
    description: constr(strip_whitespace=True) = Field(
        default="", description="description of the document"
    )

    _ensure_color_is_normalized: classmethod = validator("color", allow_reuse=True)(
        normalize_hex_color
    )

    class Config:
        schema_extra = {
            "example": {
                "color": "#374151",
                "description": "dsRNA/binding protein",
                "name": "Binding protein",
            }
        }


class CreateLabelResponse(Label):
    class Config:
        schema_extra = {
            "example": {
                "color": "#374151",
                "count": 0,
                "description": "dsRNA/binding protein",
                "id": 23,
                "name": "Binding protein",
            }
        }


class EditLabelSchema(BaseModel):
    """
    Label fields for editing an existing label.
    """

    name: constr(strip_whitespace=True) = Field(
        description="name of the existing label document"
    )
    color: constr(strip_whitespace=True)
    description: constr(strip_whitespace=True) = Field(
        description="description of the existing label document"
    )

    _ensure_color_is_normalized: classmethod = validator("color", allow_reuse=True)(
        normalize_hex_color
    )

    class Config:
        schema_extra = {
            "example": {
                "color": "#93C5FD",
                "description": "Blueberry",
                "name": "Blueberry",
            }
        }


class LabelResponse(Label):
    class Config:
        schema_extra = {
            "example": {
                "color": "#6B7280",
                "count": 0,
                "description": "dsRNA/Ab",
                "id": 22,
                "name": "Ab",
            }
        }


class GetLabelResponse(Label):
    class Config:
        schema_extra = {
            "example": [
                {
                    "color": "#6B7280",
                    "count": 0,
                    "description": "dsRNA/Ab",
                    "id": 22,
                    "name": "Ab",
                }
            ]
        }
{'fraction_non_alphanumeric': 0.10981352420418158, 'fraction_numerical': 0.013938594838952722, 'mean_word_length': 1.7230769230769232, 'pattern_counts': {'":': 52, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4785341', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1419, 'n_words': 326}