uy/sun b6e68730b7
⬆️ 适配 Pydantic V2 (#484)
* ⬆️ 适配 Pydantic V2

* 🐛 修复测试报错

* 🐛 适配忘记的 from_orm

* 🐛 忘记的 class-based `config`

* 🐛 更新 red 适配器版本
2024-02-29 19:21:25 +08:00

36 lines
759 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from abc import ABC
from pydantic import BaseModel
from nonebot.compat import PYDANTIC_V2, ConfigDict
from nonebot_plugin_saa.registries import AllSupportedPlatformTarget as UserInfo
from ....types import Tag, Category
class NBESFBase(BaseModel, ABC):
version: int # 表示nbesf格式版本有效版本从1开始
groups: list = []
if PYDANTIC_V2:
model_config = ConfigDict(from_attributes=True)
else:
class Config:
orm_mode = True
class SubReceipt(BaseModel):
"""
快递包中每件货物的收据
导入订阅时的Model
"""
user: UserInfo
target: str
target_name: str
platform_name: str
cats: list[Category]
tags: list[Tag]
# default_schedule_weight: int