From 641e58c98b75da55871df54f3e0ee49a82afccc2 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 3 Dec 2024 13:59:02 +0800 Subject: [PATCH] Fix TypeError in Pydantic V2 dumps_kwargs --- modules/pay_log/log.py | 2 +- plugins/genshin/daily/material.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/pay_log/log.py b/modules/pay_log/log.py index b6841853..2e7ca4d5 100644 --- a/modules/pay_log/log.py +++ b/modules/pay_log/log.py @@ -36,7 +36,7 @@ class PayLog: @staticmethod async def save_json(path, data: PayLogModel): async with aiofiles.open(path, "w", encoding="utf-8") as f: - return await f.write(data.json(ensure_ascii=False, indent=4, by_alias=True)) + return await f.write(data.model_dump_json(indent=4, by_alias=True)) def get_file_path( self, diff --git a/plugins/genshin/daily/material.py b/plugins/genshin/daily/material.py index 866a271f..bc7c0232 100644 --- a/plugins/genshin/daily/material.py +++ b/plugins/genshin/daily/material.py @@ -570,7 +570,7 @@ class DailyMaterial(Plugin): continue self.everyday_materials = _parse_honey_impact_source(response.content) # 当场缓存到文件 - content = self.everyday_materials.json(ensure_ascii=False, separators=(",", ":")) + content = self.everyday_materials.model_dump_json() async with aiofiles.open(DATA_FILE_PATH, "w", encoding="utf-8") as file: await file.write(content) logger.success("每日素材刷新成功")