Skip to content

Commit

Permalink
fix: 判断obj的类型
Browse files Browse the repository at this point in the history
  • Loading branch information
Night-stars-1 committed Jun 12, 2024
1 parent ff2ce37 commit 0a79431
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/models/kmou.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down

0 comments on commit 0a79431

Please sign in to comment.