Skip to content

Commit

Permalink
fix: 修复 Store 里的插件实例构造问题
Browse files Browse the repository at this point in the history
  • Loading branch information
BigOrangeQWQ committed Aug 27, 2024
1 parent ad0a6f5 commit b2db73a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils/store_test/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class StorePlugin(BaseModel):
@field_validator("tags", mode="before")
@classmethod
def tags_validator(cls, v: list[dict[str, Any]]):
"""商店里的标签数据不需要验证,直接构造即可"""
return [Tag.model_construct(**tag) for tag in v]
return [
Tag.model_construct(label=tag["label"], color=Color(tag["color"]))
for tag in v
]


class Metadata(BaseModel):
Expand Down Expand Up @@ -83,8 +85,10 @@ def metadata(self) -> Metadata:
@field_validator("tags", mode="before")
@classmethod
def tags_validator(cls, v: list[dict[str, Any]]):
"""商店里的标签数据不需要验证,直接构造即可"""
return [Tag.model_construct(**tag) for tag in v]
return [
Tag.model_construct(label=tag["label"], color=Color(tag["color"]))
for tag in v
]


class TestResult(BaseModel):
Expand Down

0 comments on commit b2db73a

Please sign in to comment.