mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-13 20:38:39 +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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user