From 0f89fe858a6f4b3636cb771376c1eae278cb0cda Mon Sep 17 00:00:00 2001 From: Bingsu Date: Wed, 26 Apr 2023 16:00:52 +0900 Subject: [PATCH] fix: dataclass to pydantic dataclass --- adetailer/common.py | 12 ++++++++---- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/adetailer/common.py b/adetailer/common.py index 89cb930..bbf6ba7 100644 --- a/adetailer/common.py +++ b/adetailer/common.py @@ -1,18 +1,22 @@ from __future__ import annotations from collections import OrderedDict -from dataclasses import dataclass from pathlib import Path +from typing import Optional from huggingface_hub import hf_hub_download from PIL import Image, ImageDraw +from pydantic.dataclasses import dataclass @dataclass class PredictOutput: - bboxes: list[list[int]] | None = None - masks: list[Image.Image] | None = None - preview: Image.Image | None = None + bboxes: Optional[list[list[int]]] = None + masks: Optional[list[Image.Image]] = None + preview: Optional[Image.Image] = None + + class Config: + arbitrary_types_allowed = True def get_models(model_dir: str | Path) -> OrderedDict[str, str | None]: diff --git a/pyproject.toml b/pyproject.toml index 508dcdf..56a7977 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ known_first_party = ["modules", "launch"] [tool.ruff] select = ["A", "B", "C4", "E", "F", "I001", "ISC", "N", "PIE", "PT", "RET", "SIM", "UP", "W"] -ignore = ["B008", "B905", "E501"] +ignore = ["B008", "B905", "E501", "UP007"] unfixable = ["F401"] [tool.ruff.isort]