From 0a79431907beab48f2c5172dc8035bcf1e5a9b8f Mon Sep 17 00:00:00 2001 From: Night-stars-1 Date: Wed, 12 Jun 2024 23:49:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A4=E6=96=ADobj=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/models/kmou.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/models/kmou.py b/core/models/kmou.py index 60010dd..38d4a73 100644 --- a/core/models/kmou.py +++ b/core/models/kmou.py @@ -5,7 +5,7 @@ LastEditors: Night-stars-1 nujj1042633805@gmail.com """ -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Union from core.exceptions import StopExecution @@ -20,12 +20,13 @@ def __init__(self, **data) -> None: @classmethod def model_validate( self, - obj: dict, + obj: Union[dict, list], strict: Optional[bool] = None, from_attributes: Optional[bool] = None, context: Optional[Dict[str, Any]] = None, ) -> GoodsModel: - assert obj.get("error") == None, obj["error"] + if isinstance(obj, dict): + assert obj.get("error") == None, obj["error"] new_obj = [] for good in obj: good["type"] = "sell" if good["type"] == "buy" else "buy"