From da105eb3dd66935401c7740a132b3d18d77294ec Mon Sep 17 00:00:00 2001 From: Colin Wilk Date: Mon, 2 Oct 2023 01:10:42 +0200 Subject: Add pydantic to dataclasses Verifies the type annotations on the classes. This commit also fixes a bug where an invalid type was returned for suggestions of a Tag. The return type was a dict of a Micro Tag Structure but it was expected to be a string (see szurubooru.py) Signed-off-by: Colin Wilk --- src/lib/dataclasses.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/lib/dataclasses.py') diff --git a/src/lib/dataclasses.py b/src/lib/dataclasses.py index 16413b7..6313fca 100644 --- a/src/lib/dataclasses.py +++ b/src/lib/dataclasses.py @@ -3,8 +3,9 @@ Module for collection of dataclasses that map Szurubooru objects to python class """ -from dataclasses import dataclass, field -from typing import List +from pydantic.dataclasses import dataclass +from dataclasses import field +from typing import List, Optional @dataclass @@ -40,7 +41,7 @@ class Tag: name: str version: int = -1 - description: str = "" + description: Optional[str] = "" category: str = "General" implications: List[str] = field(default_factory=list) suggestions: List[str] = field(default_factory=list) -- cgit v1.2.3