Fix TypeError in Pydantic V2 dumps_kwargs

This commit is contained in:
xtaodada 2024-12-03 13:59:02 +08:00
parent 4c4d69a492
commit 641e58c98b
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 2 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class PayLog:
@staticmethod @staticmethod
async def save_json(path, data: PayLogModel): async def save_json(path, data: PayLogModel):
async with aiofiles.open(path, "w", encoding="utf-8") as f: 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( def get_file_path(
self, self,

View File

@ -570,7 +570,7 @@ class DailyMaterial(Plugin):
continue continue
self.everyday_materials = _parse_honey_impact_source(response.content) 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: async with aiofiles.open(DATA_FILE_PATH, "w", encoding="utf-8") as file:
await file.write(content) await file.write(content)
logger.success("每日素材刷新成功") logger.success("每日素材刷新成功")