🎨 按ruff的检查调整程序代码

This commit is contained in:
Azide
2023-07-16 00:22:20 +08:00
committed by felinae98
parent f232ce4c3e
commit dba8f2a9cb
42 changed files with 414 additions and 757 deletions
@@ -1,15 +1,14 @@
from abc import ABC
from nonebot_plugin_saa.utils import AllSupportedPlatformTarget as UserInfo
from pydantic import BaseModel
from nonebot_plugin_saa.utils import AllSupportedPlatformTarget as UserInfo
from ....types import Category, Tag
from ....types import Tag, Category
class NBESFBase(BaseModel, ABC):
version: int # 表示nbesf格式版本,有效版本从1开始
groups: list = list()
groups: list = []
class Config:
orm_mode = True
+10 -9
View File
@@ -1,25 +1,26 @@
from typing import cast
from collections import defaultdict
from typing import Callable, cast
from collections.abc import Callable
from nonebot.log import logger
from nonebot_plugin_datastore.db import create_session
from nonebot_plugin_saa import PlatformTarget
from sqlalchemy import select
from sqlalchemy.orm.strategy_options import selectinload
from nonebot.log import logger
from sqlalchemy.sql.selectable import Select
from nonebot_plugin_saa import PlatformTarget
from nonebot_plugin_datastore.db import create_session
from sqlalchemy.orm.strategy_options import selectinload
from ..db_model import Subscribe, User
from .nbesf_model import NBESFBase, v1, v2
from .utils import NBESFVerMatchErr
from ..db_model import User, Subscribe
from .nbesf_model import NBESFBase, v1, v2
async def subscribes_export(selector: Callable[[Select], Select]) -> v2.SubGroup:
"""
将Bison订阅导出为 Nonebot Bison Exchangable Subscribes File 标准格式的 SubGroup 类型数据
selector:
对 sqlalchemy Select 对象的操作函数,用于限定查询范围 e.g. lambda stmt: stmt.where(User.uid=2233, User.type="group")
对 sqlalchemy Select 对象的操作函数,用于限定查询范围
e.g. lambda stmt: stmt.where(User.uid=2233, User.type="group")
"""
async with create_session() as sess:
sub_stmt = select(Subscribe).join(User)