Skip to content

Commit

Permalink
🚨 Make pyright happy (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
BalconyJH authored Jan 26, 2025
1 parent 40779e0 commit d6fd5f1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
5 changes: 3 additions & 2 deletions zhenxun/builtin_plugins/shop/_data_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
from collections.abc import Callable
from dataclasses import field
from datetime import datetime, timedelta
import inspect
import time
Expand Down Expand Up @@ -32,9 +33,9 @@
class Goods(BaseModel):
name: str
"""商品名称"""
before_handle: list[Callable] = []
before_handle: list[Callable] = field(default_factory=list)
"""使用前函数"""
after_handle: list[Callable] = []
after_handle: list[Callable] = field(default_factory=list)
"""使用后函数"""
func: Callable | None = None
"""使用函数"""
Expand Down
6 changes: 4 additions & 2 deletions zhenxun/builtin_plugins/web_ui/api/tabs/manage/model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from dataclasses import field

from nonebot.compat import model_dump
from pydantic import BaseModel

Expand Down Expand Up @@ -172,9 +174,9 @@ class ReqResult(BaseModel):
好友/群组请求列表
"""

friend: list[FriendRequestResult] = []
friend: list[FriendRequestResult] = field(default_factory=list)
"""好友请求列表"""
group: list[GroupRequestResult] = []
group: list[GroupRequestResult] = field(default_factory=list)
"""群组请求列表"""


Expand Down
5 changes: 3 additions & 2 deletions zhenxun/configs/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from dataclasses import field
from pathlib import Path

import nonebot
Expand All @@ -13,9 +14,9 @@ class BotSetting(BaseModel):
"""系统代理"""
db_url: str = ""
"""数据库链接"""
platform_superusers: dict[str, list[str]] = {}
platform_superusers: dict[str, list[str]] = field(default_factory=dict)
"""平台超级用户"""
qbot_id_data: dict[str, str] = {}
qbot_id_data: dict[str, str] = field(default_factory=dict)
"""官bot id:账号id"""

def get_qbot_uid(self, qbot_id: str) -> str | None:
Expand Down
14 changes: 7 additions & 7 deletions zhenxun/configs/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import defaultdict
from collections.abc import Callable
import copy
from dataclasses import field
from datetime import datetime
from pathlib import Path
from typing import Any, Literal
Expand Down Expand Up @@ -38,11 +38,11 @@ class Command(BaseModel):

command: str
"""命令名称"""
params: list[str] = []
params: list[str] = field(default_factory=list)
"""参数"""
description: str = ""
"""描述"""
examples: list[Example] = []
examples: list[Example] = field(default_factory=list)
"""示例列表"""


Expand Down Expand Up @@ -96,7 +96,7 @@ class ConfigGroup(BaseModel):
"""模块名"""
name: str | None = None
"""插件名"""
configs: dict[str, ConfigModel] = defaultdict()
configs: dict[str, ConfigModel] = field(default_factory=dict)
"""配置项列表"""

def get(self, c: str, default: Any = None) -> Any:
Expand Down Expand Up @@ -209,7 +209,7 @@ class Task(BaseBlock):
"""运行函数"""
check: Callable | None = None
"""检查函数"""
check_args: list = []
check_args: list = field(default_factory=list)
"""检查函数参数"""


Expand All @@ -234,15 +234,15 @@ class PluginExtraData(BaseModel):
"""插件基本配置"""
limits: list[BaseBlock | PluginCdBlock | PluginCountBlock] | None = None
"""插件限制"""
commands: list[Command] = []
commands: list[Command] = field(default_factory=list)
"""命令列表,用于说明帮助"""
ignore_prompt: bool = False
"""是否忽略阻断提示"""
tasks: list[Task] | None = None
"""技能被动"""
superuser_help: str | None = None
"""超级用户帮助"""
aliases: set[str] = set()
aliases: set[str] = field(default_factory=set)
"""额外名称"""
sql_list: list[str] | None = None
"""常用sql"""
Expand Down
9 changes: 5 additions & 4 deletions zhenxun/utils/_build_mat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from dataclasses import field
from io import BytesIO
from pathlib import Path
import random
Expand All @@ -20,15 +21,15 @@ class MatType(StrEnum):
class BuildMatData(BaseModel):
mat_type: MatType
"""类型"""
data: list[int | float] = []
data: list[int | float] = field(default_factory=list)
"""数据"""
x_name: str | None = None
"""X轴坐标名称"""
y_name: str | None = None
"""Y轴坐标名称"""
x_index: list[str] = []
x_index: list[str] = field(default_factory=list)
"""显示轴坐标值"""
y_index: list[int | float] = []
y_index: list[int | float] = field(default_factory=list)
"""数据轴坐标值"""
space: tuple[int, int] = (20, 20)
"""坐标值间隔(X, Y)"""
Expand All @@ -48,7 +49,7 @@ class BuildMatData(BaseModel):
"""背景颜色"""
background: Path | bytes | None = None
"""背景图片"""
bar_color: list[str] = ["*"]
bar_color: list[str] = field(default_factory=lambda: ["*"])
"""柱状图柱子颜色, 多个时随机, 使用 * 时七色随机"""
padding: tuple[int, int] = (50, 50)
"""图表上下左右边距"""
Expand Down
7 changes: 4 additions & 3 deletions zhenxun/utils/decorator/shop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Callable
from dataclasses import field

from nonebot.adapters.onebot.v11 import Message, MessageSegment
from nonebot.plugin import require
Expand All @@ -8,8 +9,8 @@


class Goods(BaseModel):
before_handle: list[Callable] = []
after_handle: list[Callable] = []
before_handle: list[Callable] = field(default_factory=list)
after_handle: list[Callable] = field(default_factory=list)
price: int
des: str = ""
discount: float
Expand All @@ -19,7 +20,7 @@ class Goods(BaseModel):
is_passive: bool
partition: str | None
func: Callable
kwargs: dict[str, str] = {}
kwargs: dict[str, str] = field(default_factory=dict)
send_success_msg: bool
max_num_limit: int

Expand Down
3 changes: 2 additions & 1 deletion zhenxun/utils/github_utils/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from dataclasses import field
from typing import Protocol

from aiocache import cached
Expand Down Expand Up @@ -99,7 +100,7 @@ class FileInfo(BaseModel):

type: FileType
name: str
files: list["FileInfo"] = []
files: list["FileInfo"] = field(default_factory=list)


class JsdelivrStrategy:
Expand Down

0 comments on commit d6fd5f1

Please sign in to comment.