🐛 修正项目的代码警告 (#614)

* 🐛 调整ruff的pytest警告

* 🐛 调整导入关系警告

* 🐛 删除奇怪无用的赋值和取值逻辑

*  不同测试部分所用变量应加以区分

* 🐛 subs_io model添加默认值

* 🐛 修完所有的 ruff PT001 警告

* 🔧 按ruff建议修改ruff配置

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Azide
2024-08-17 18:24:20 +08:00
committed by GitHub
parent 29f23eb3c7
commit 32e3bcc022
26 changed files with 87 additions and 88 deletions
@@ -79,7 +79,7 @@ class SubGroup(
"""
version: int = NBESF_VERSION
groups: list[SubPack]
groups: list[SubPack] = []
# ======================= #
@@ -64,7 +64,7 @@ class SubGroup(NBESFBase):
"""
version: int = NBESF_VERSION
groups: list[SubPack]
groups: list[SubPack] = []
# ======================= #
+2 -2
View File
@@ -5,7 +5,7 @@ from datetime import datetime
from urllib.parse import unquote
from yarl import URL
from lxml import etree
from lxml.etree import HTML
from httpx import AsyncClient
from nonebot.log import logger
from bs4 import BeautifulSoup as bs
@@ -131,7 +131,7 @@ class Weibo(NewMessage):
def _get_text(self, raw_text: str) -> str:
text = raw_text.replace("<br/>", "\n").replace("<br />", "\n")
selector = etree.HTML(text, parser=None)
selector = HTML(text, parser=None)
if selector is None:
return text
url_elems = selector.xpath("//a[@href]/span[@class='surl-text']")
+3 -2
View File
@@ -19,6 +19,7 @@ try:
import anyio
import click
from anyio import to_thread, from_thread
except ImportError as e: # pragma: no cover
raise ImportError("请使用 `pip install nonebot-bison[cli]` 安装所需依赖") from e
@@ -39,7 +40,7 @@ R = TypeVar("R")
def run_sync(func: Callable[P, R]) -> Callable[P, Coroutine[Any, Any, R]]:
@wraps(func)
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
return await anyio.to_thread.run_sync(partial(func, *args, **kwargs))
return await to_thread.run_sync(partial(func, *args, **kwargs))
return wrapper
@@ -47,7 +48,7 @@ def run_sync(func: Callable[P, R]) -> Callable[P, Coroutine[Any, Any, R]]:
def run_async(func: Callable[P, Coroutine[Any, Any, R]]) -> Callable[P, R]:
@wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
return anyio.from_thread.run(partial(func, *args, **kwargs))
return from_thread.run(partial(func, *args, **kwargs))
return wrapper
-3
View File
@@ -68,9 +68,6 @@ async def do_choose_group_number(state: T_State, event: PrivateMessageEvent, gro
idx = int(group_idx)
if idx not in group_number_idx.keys():
await group_manage_matcher.reject("请输入正确序号")
state["group_idx"] = idx
group_number_idx: dict[int, int] = state["group_number_idx"]
idx: int = state["group_idx"]
group_id = group_number_idx[idx]
state["target_user_info"] = TargetQQGroup(group_id=group_id)