mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
🐛 修正项目的代码警告 (#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:
parent
29f23eb3c7
commit
32e3bcc022
@ -7,7 +7,7 @@ ci:
|
||||
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.5.6
|
||||
rev: v0.6.0
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
@ -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] = []
|
||||
|
||||
|
||||
# ======================= #
|
||||
|
@ -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']")
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
40
poetry.lock
generated
40
poetry.lock
generated
@ -4170,29 +4170,29 @@ reference = "offical-source"
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.5.2"
|
||||
version = "0.6.0"
|
||||
description = "An extremely fast Python linter and code formatter, written in Rust."
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "ruff-0.5.2-py3-none-linux_armv6l.whl", hash = "sha256:7bab8345df60f9368d5f4594bfb8b71157496b44c30ff035d1d01972e764d3be"},
|
||||
{file = "ruff-0.5.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:1aa7acad382ada0189dbe76095cf0a36cd0036779607c397ffdea16517f535b1"},
|
||||
{file = "ruff-0.5.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:aec618d5a0cdba5592c60c2dee7d9c865180627f1a4a691257dea14ac1aa264d"},
|
||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0b62adc5ce81780ff04077e88bac0986363e4a3260ad3ef11ae9c14aa0e67ef"},
|
||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:dc42ebf56ede83cb080a50eba35a06e636775649a1ffd03dc986533f878702a3"},
|
||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c15c6e9f88c67ffa442681365d11df38afb11059fc44238e71a9d9f1fd51de70"},
|
||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d3de9a5960f72c335ef00763d861fc5005ef0644cb260ba1b5a115a102157251"},
|
||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fe5a968ae933e8f7627a7b2fc8893336ac2be0eb0aace762d3421f6e8f7b7f83"},
|
||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a04f54a9018f75615ae52f36ea1c5515e356e5d5e214b22609ddb546baef7132"},
|
||||
{file = "ruff-0.5.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ed02fb52e3741f0738db5f93e10ae0fb5c71eb33a4f2ba87c9a2fa97462a649"},
|
||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3cf8fe659f6362530435d97d738eb413e9f090e7e993f88711b0377fbdc99f60"},
|
||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:237a37e673e9f3cbfff0d2243e797c4862a44c93d2f52a52021c1a1b0899f846"},
|
||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:2a2949ce7c1cbd8317432ada80fe32156df825b2fd611688814c8557824ef060"},
|
||||
{file = "ruff-0.5.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:481af57c8e99da92ad168924fd82220266043c8255942a1cb87958b108ac9335"},
|
||||
{file = "ruff-0.5.2-py3-none-win32.whl", hash = "sha256:f1aea290c56d913e363066d83d3fc26848814a1fed3d72144ff9c930e8c7c718"},
|
||||
{file = "ruff-0.5.2-py3-none-win_amd64.whl", hash = "sha256:8532660b72b5d94d2a0a7a27ae7b9b40053662d00357bb2a6864dd7e38819084"},
|
||||
{file = "ruff-0.5.2-py3-none-win_arm64.whl", hash = "sha256:73439805c5cb68f364d826a5c5c4b6c798ded6b7ebaa4011f01ce6c94e4d5583"},
|
||||
{file = "ruff-0.5.2.tar.gz", hash = "sha256:2c0df2d2de685433794a14d8d2e240df619b748fbe3367346baa519d8e6f1ca2"},
|
||||
{file = "ruff-0.6.0-py3-none-linux_armv6l.whl", hash = "sha256:92dcce923e5df265781e5fc76f9a1edad52201a7aafe56e586b90988d5239013"},
|
||||
{file = "ruff-0.6.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:31b90ff9dc79ed476c04e957ba7e2b95c3fceb76148f2079d0d68a908d2cfae7"},
|
||||
{file = "ruff-0.6.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6d834a9ec9f8287dd6c3297058b3a265ed6b59233db22593379ee38ebc4b9768"},
|
||||
{file = "ruff-0.6.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f2089267692696aba342179471831a085043f218706e642564812145df8b8d0d"},
|
||||
{file = "ruff-0.6.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:aa62b423ee4bbd8765f2c1dbe8f6aac203e0583993a91453dc0a449d465c84da"},
|
||||
{file = "ruff-0.6.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7344e1a964b16b1137ea361d6516ce4ee61a0403fa94252a1913ecc1311adcae"},
|
||||
{file = "ruff-0.6.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:487f3a35c3f33bf82be212ce15dc6278ea854e35573a3f809442f73bec8b2760"},
|
||||
{file = "ruff-0.6.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:75db409984077a793cf344d499165298a6f65449e905747ac65983b12e3e64b1"},
|
||||
{file = "ruff-0.6.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:84908bd603533ecf1db456d8fc2665d1f4335d722e84bc871d3bbd2d1116c272"},
|
||||
{file = "ruff-0.6.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f1749a0aef3ec41ed91a0e2127a6ae97d2e2853af16dbd4f3c00d7a3af726c5"},
|
||||
{file = "ruff-0.6.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:016fea751e2bcfbbd2f8cb19b97b37b3fd33148e4df45b526e87096f4e17354f"},
|
||||
{file = "ruff-0.6.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:6ae80f141b53b2e36e230017e64f5ea2def18fac14334ffceaae1b780d70c4f7"},
|
||||
{file = "ruff-0.6.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:eaaaf33ea4b3f63fd264d6a6f4a73fa224bbfda4b438ffea59a5340f4afa2bb5"},
|
||||
{file = "ruff-0.6.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7667ddd1fc688150a7ca4137140867584c63309695a30016880caf20831503a0"},
|
||||
{file = "ruff-0.6.0-py3-none-win32.whl", hash = "sha256:ae48365aae60d40865a412356f8c6f2c0be1c928591168111eaf07eaefa6bea3"},
|
||||
{file = "ruff-0.6.0-py3-none-win_amd64.whl", hash = "sha256:774032b507c96f0c803c8237ce7d2ef3934df208a09c40fa809c2931f957fe5e"},
|
||||
{file = "ruff-0.6.0-py3-none-win_arm64.whl", hash = "sha256:a5366e8c3ae6b2dc32821749b532606c42e609a99b0ae1472cf601da931a048c"},
|
||||
{file = "ruff-0.6.0.tar.gz", hash = "sha256:272a81830f68f9bd19d49eaf7fa01a5545c5a2e86f32a9935bb0e4bb9a1db5b8"},
|
||||
]
|
||||
|
||||
[package.source]
|
||||
@ -5112,4 +5112,4 @@ yaml = []
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">=3.10,<4.0.0"
|
||||
content-hash = "d685583bbdceb8277e33e71357fb9c9e781c6388911cd09aa5a0153605ae38ae"
|
||||
content-hash = "ff257fd8abf0e5a15fc3900dd4c295c45b70ea3e9a76e3822e26b35728260317"
|
||||
|
@ -50,7 +50,7 @@ isort = "^5.13.2"
|
||||
nonemoji = "^0.1.4"
|
||||
nb-cli = "^1.4.1"
|
||||
pre-commit = "^3.7.1"
|
||||
ruff = ">=0.5.1"
|
||||
ruff = "^0.6.0"
|
||||
|
||||
[tool.poetry.group.test.dependencies]
|
||||
flaky = "^3.8.1"
|
||||
@ -95,12 +95,13 @@ markers = [
|
||||
asyncio_mode = "auto"
|
||||
|
||||
[tool.ruff]
|
||||
select = ["E", "W", "F", "UP", "C", "T", "PYI", "PT", "Q"]
|
||||
ignore = ["E402", "C901", "PT023"]
|
||||
|
||||
line-length = 120
|
||||
target-version = "py310"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "W", "F", "UP", "C", "T", "PYI", "PT", "Q"]
|
||||
ignore = ["E402", "C901", "PT023"]
|
||||
|
||||
[tool.black]
|
||||
line-length = 120
|
||||
preview = true
|
||||
|
@ -10,7 +10,7 @@ if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.config.config_legacy import Config
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def config_legacy(app: App, use_legacy_config):
|
||||
from nonebot_bison.config import config_legacy as config
|
||||
|
||||
|
@ -52,18 +52,18 @@ async def test_add_subscribe(app: App, init_scheduler):
|
||||
)
|
||||
confs = await config.list_subscribe(TargetQQGroup(group_id=123))
|
||||
assert len(confs) == 1
|
||||
conf: Subscribe = confs[0]
|
||||
conf2: Subscribe = confs[0]
|
||||
async with AsyncSession(get_engine()) as sess:
|
||||
related_user_obj = await sess.scalar(select(User).where(User.id == conf.user_id))
|
||||
related_target_obj = await sess.scalar(select(Target).where(Target.id == conf.target_id))
|
||||
related_user_obj = await sess.scalar(select(User).where(User.id == conf2.user_id))
|
||||
related_target_obj = await sess.scalar(select(Target).where(Target.id == conf2.target_id))
|
||||
assert related_user_obj
|
||||
assert related_target_obj
|
||||
assert related_user_obj.user_target["group_id"] == 123
|
||||
assert related_target_obj.target_name == "weibo_name2"
|
||||
assert related_target_obj.target == "weibo_id"
|
||||
assert conf.target.target == "weibo_id"
|
||||
assert conf.categories == [1]
|
||||
assert conf.tags == ["tag"]
|
||||
assert conf2.target.target == "weibo_id"
|
||||
assert conf2.categories == [1]
|
||||
assert conf2.tags == ["tag"]
|
||||
|
||||
|
||||
async def test_add_dup_sub(init_scheduler):
|
||||
|
@ -28,7 +28,7 @@ def load_adapters(nonebug_init: None):
|
||||
return driver
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
async def app(tmp_path: Path, request: pytest.FixtureRequest, mocker: MockerFixture):
|
||||
sys.path.append(str(Path(__file__).parent.parent / "src" / "plugins"))
|
||||
|
||||
@ -75,7 +75,7 @@ async def app(tmp_path: Path, request: pytest.FixtureRequest, mocker: MockerFixt
|
||||
cache_dir.mkdir()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_user_subinfo(app: App):
|
||||
from nonebot_plugin_saa import TargetQQGroup
|
||||
|
||||
@ -85,14 +85,14 @@ def dummy_user_subinfo(app: App):
|
||||
return UserSubInfo(user=user, categories=[], tags=[])
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
async def init_scheduler(app: App):
|
||||
from nonebot_bison.scheduler.manager import init_scheduler
|
||||
|
||||
return await init_scheduler()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
async def use_legacy_config(app: App):
|
||||
import aiofiles
|
||||
|
||||
|
@ -9,7 +9,7 @@ from nonebot.compat import model_dump, type_validate_python
|
||||
from .utils import get_file, get_json
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def arknights(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
|
@ -15,7 +15,7 @@ from nonebot.compat import model_dump, type_validate_python
|
||||
from .utils import get_json
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def bing_dy_list(app: App):
|
||||
from nonebot_bison.platform.bilibili.models import PostAPI
|
||||
|
||||
@ -26,7 +26,7 @@ if TYPE_CHECKING:
|
||||
from nonebot_bison.platform.bilibili import Bilibili
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def bilibili(app: App) -> "Bilibili":
|
||||
from nonebot_bison.utils import ProcessContext
|
||||
from nonebot_bison.platform import platform_manager
|
||||
@ -35,7 +35,7 @@ def bilibili(app: App) -> "Bilibili":
|
||||
return platform_manager["bilibili"](ProcessContext(BilibiliClientManager())) # type: ignore
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def without_dynamic(app: App):
|
||||
from nonebot_bison.platform.bilibili.models import PostAPI
|
||||
|
||||
|
@ -11,7 +11,7 @@ if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.bilibili import BilibiliBangumi
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def bili_bangumi(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
|
@ -12,7 +12,7 @@ if TYPE_CHECKING:
|
||||
from nonebot_bison.platform.bilibili import Bilibililive
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def bili_live(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
@ -20,7 +20,7 @@ def bili_live(app: App):
|
||||
return platform_manager["bilibili-live"](ProcessContext(DefaultClientManager()))
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_only_open_user_subinfo(app: App):
|
||||
from nonebot_plugin_saa import TargetQQGroup
|
||||
|
||||
@ -131,7 +131,7 @@ async def test_fetch_bililive_only_live_open(bili_live: "Bilibililive", dummy_on
|
||||
assert len(res4[0][1]) == 0
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_only_title_user_subinfo(app: App):
|
||||
from nonebot_plugin_saa import TargetQQGroup
|
||||
|
||||
@ -190,7 +190,7 @@ async def test_fetch_bililive_only_title_change(bili_live, dummy_only_title_user
|
||||
assert len(res4[0][1]) == 0
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_only_close_user_subinfo(app: App):
|
||||
from nonebot_plugin_saa import TargetQQGroup
|
||||
|
||||
@ -250,7 +250,7 @@ async def test_fetch_bililive_only_close(bili_live, dummy_only_close_user_subinf
|
||||
assert post4.compress is True
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_bililive_user_subinfo(app: App):
|
||||
from nonebot_plugin_saa import TargetQQGroup
|
||||
|
||||
|
@ -12,7 +12,7 @@ if TYPE_CHECKING:
|
||||
from nonebot_bison.platform.ceobecanteen import CeobeCanteen
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_only_open_user_subinfo(app: App):
|
||||
from nonebot_plugin_saa import TargetQQGroup
|
||||
|
||||
@ -22,7 +22,7 @@ def dummy_only_open_user_subinfo(app: App):
|
||||
return UserSubInfo(user=user, categories=[1], tags=[])
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def ceobecanteen(app: App):
|
||||
from nonebot_bison.utils import ProcessContext
|
||||
from nonebot_bison.platform import platform_manager
|
||||
|
@ -6,7 +6,7 @@ from nonebug.app import App
|
||||
from .utils import get_json
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def ff14(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
|
@ -12,7 +12,7 @@ if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.ncm import NcmArtist
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def ncm_artist(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
|
@ -12,7 +12,7 @@ if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.platform.ncm import NcmRadio
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def ncm_radio(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
|
@ -16,7 +16,7 @@ raw_post_list_2 = raw_post_list_1 + [
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_user(app: App):
|
||||
from nonebot_plugin_saa import TargetQQGroup
|
||||
|
||||
@ -24,7 +24,7 @@ def dummy_user(app: App):
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def user_info_factory(app: App, dummy_user):
|
||||
from nonebot_bison.types import UserSubInfo
|
||||
|
||||
@ -34,7 +34,7 @@ def user_info_factory(app: App, dummy_user):
|
||||
return _user_info
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_platform_without_cats_tags(app: App):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.types import Target, RawPost
|
||||
@ -81,7 +81,7 @@ def mock_platform_without_cats_tags(app: App):
|
||||
return MockPlatform
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_platform(app: App):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.utils import Site
|
||||
@ -143,7 +143,7 @@ def mock_platform(app: App):
|
||||
return MockPlatform
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_site(app):
|
||||
from nonebot_bison.utils import Site
|
||||
|
||||
@ -155,7 +155,7 @@ def mock_site(app):
|
||||
return MockSite
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_platform_no_target(app: App, mock_site):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.types import Tag, Target, RawPost, Category
|
||||
@ -210,7 +210,7 @@ def mock_platform_no_target(app: App, mock_site):
|
||||
return MockPlatform
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_platform_no_target_2(app: App, mock_site):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.platform.platform import NewMessage
|
||||
@ -272,7 +272,7 @@ def mock_platform_no_target_2(app: App, mock_site):
|
||||
return MockPlatform
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_status_change(app: App):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.platform.platform import StatusChange
|
||||
|
@ -14,7 +14,7 @@ if typing.TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def dummy_user(app: App):
|
||||
from nonebot_bison.types import User
|
||||
|
||||
@ -22,7 +22,7 @@ def dummy_user(app: App):
|
||||
return user
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def user_info_factory(app: App, dummy_user):
|
||||
from nonebot_bison.types import UserSubInfo
|
||||
|
||||
@ -32,7 +32,7 @@ def user_info_factory(app: App, dummy_user):
|
||||
return _user_info
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def rss(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
@ -40,7 +40,7 @@ def rss(app: App):
|
||||
return platform_manager["rss"](ProcessContext(DefaultClientManager()))
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def update_time_feed_1():
|
||||
file = get_file("rss-twitter-ArknightsStaff.xml")
|
||||
root = ET.fromstring(file)
|
||||
@ -53,7 +53,7 @@ def update_time_feed_1():
|
||||
return ET.tostring(root, encoding="unicode")
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def update_time_feed_2():
|
||||
file = get_file("rss-ruanyifeng.xml")
|
||||
root = ET.fromstring(file)
|
||||
@ -119,7 +119,7 @@ async def test_fetch_new_2(
|
||||
assert post1.content == "这里记录每周值得分享的科技内容,周五发布。..."
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def update_time_feed_3():
|
||||
file = get_file("rss-github-atom.xml")
|
||||
root = ET.fromstring(file)
|
||||
|
@ -16,7 +16,7 @@ if typing.TYPE_CHECKING:
|
||||
image_cdn_router = respx.route(host__regex=r"wx\d.sinaimg.cn", path__startswith="/large/")
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def weibo(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
|
@ -18,7 +18,7 @@ raw_post_list_2 = raw_post_list_1 + [
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_platform(app: App):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.types import Target, RawPost
|
||||
|
@ -138,10 +138,10 @@ async def test_subs_import_v1(app: App, tmp_path):
|
||||
assert result.exit_code == 0
|
||||
assert len(await config.list_subs_with_all_info()) == 3
|
||||
|
||||
mock_file: Path = tmp_path / "2.yaml"
|
||||
mock_file.write_text(get_file("v1/subs_export.yaml"))
|
||||
mock_file2: Path = tmp_path / "2.yaml"
|
||||
mock_file2.write_text(get_file("v1/subs_export.yaml"))
|
||||
|
||||
result = await run_sync(runner.invoke)(cli, ["import", "-p", str(mock_file), "--format=yml"])
|
||||
result = await run_sync(runner.invoke)(cli, ["import", "-p", str(mock_file2), "--format=yml"])
|
||||
assert result.exit_code == 0
|
||||
assert len(await config.list_subs_with_all_info()) == 6
|
||||
|
||||
@ -169,9 +169,9 @@ async def test_sub_import_v2(app: App, tmp_path):
|
||||
assert result.exit_code == 0
|
||||
assert len(await config.list_subs_with_all_info()) == 3
|
||||
|
||||
mock_file: Path = tmp_path / "2.yaml"
|
||||
mock_file.write_text(get_file("v2/subs_export.yaml"))
|
||||
mock_file2: Path = tmp_path / "2.yaml"
|
||||
mock_file2.write_text(get_file("v2/subs_export.yaml"))
|
||||
|
||||
result = await run_sync(runner.invoke)(cli, ["import", "-p", str(mock_file), "--format=yml"])
|
||||
result = await run_sync(runner.invoke)(cli, ["import", "-p", str(mock_file2), "--format=yml"])
|
||||
assert result.exit_code == 0
|
||||
assert len(await config.list_subs_with_all_info()) == 6
|
||||
|
@ -52,12 +52,12 @@ async def download_imgs(url_list: list[str]) -> list[bytes]:
|
||||
return img_contents
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
async def downloaded_resource():
|
||||
return await download_imgs(merge_source_9)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
async def downloaded_resource_2():
|
||||
return await download_imgs(merge_source_9_2)
|
||||
|
||||
|
@ -22,19 +22,19 @@ raw_post_list_2 = raw_post_list_1 + [
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def MERGEABLE_PNG_DATA() -> bytes:
|
||||
from tests.platforms.utils import get_bytes
|
||||
|
||||
return get_bytes("mergeable-pic.jpg")
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def SIMPLE_PNG_DATA() -> bytes:
|
||||
return b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89"
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_platform(app: App):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.types import Target, RawPost
|
||||
@ -81,7 +81,7 @@ def mock_platform(app: App):
|
||||
return MockPlatform
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def mock_post(app: App, mock_platform):
|
||||
from nonebot_bison.post import Post
|
||||
from nonebot_bison.utils import ProcessContext, DefaultClientManager
|
||||
|
Loading…
x
Reference in New Issue
Block a user