From b82053be11803077c437b969db7f6f060566896b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 21:49:16 +0000 Subject: [PATCH] :arrow_up: auto update by pre-commit hooks (#548) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :arrow_up: auto update by pre-commit hooks updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.13 → v0.12.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.13...v0.12.3) * :rotating_light: auto fix by pre-commit hooks * ⬆️ Upgrade dependency ruff to v0.12.4 * 🚨 修复 lint 警告 * 🚨 添加一个 noqa( --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: 呵呵です <51957264+shoucandanghehe@users.noreply.github.com> Co-authored-by: shoucandanghehe --- .pre-commit-config.yaml | 2 +- .../3c25a5a8c050_refactor_historical.py | 2 +- .../migrations/6c3206f90cc3_add_field.py | 4 ++-- .../766cc7e75a62_migrate_to_uninfo.py | 5 ++++- ...ce14d_correct_the_data_in_historicaldata.py | 10 +++++----- ...39a_add_user_unique_identifier_field_to_.py | 18 ++++++++++-------- nonebot_plugin_tetris_stats/games/schemas.py | 2 ++ nonebot_plugin_tetris_stats/i18n/__init__.py | 2 +- .../utils/render/avatar/draw/__init__.py | 4 ++-- tests/tetrio/test_bind.py | 2 +- 10 files changed, 29 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 84746e4..e8088db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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.11.13 + rev: v0.12.4 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/nonebot_plugin_tetris_stats/config/migrations/3c25a5a8c050_refactor_historical.py b/nonebot_plugin_tetris_stats/config/migrations/3c25a5a8c050_refactor_historical.py index a97ffa6..2f5b593 100644 --- a/nonebot_plugin_tetris_stats/config/migrations/3c25a5a8c050_refactor_historical.py +++ b/nonebot_plugin_tetris_stats/config/migrations/3c25a5a8c050_refactor_historical.py @@ -29,7 +29,7 @@ depends_on: str | Sequence[str] | None = None def migrate_old_data() -> None: # noqa: C901 - from json import dumps, loads + from json import dumps, loads # noqa: PLC0415 Base = automap_base() # noqa: N806 Base.prepare(autoload_with=op.get_bind()) diff --git a/nonebot_plugin_tetris_stats/config/migrations/6c3206f90cc3_add_field.py b/nonebot_plugin_tetris_stats/config/migrations/6c3206f90cc3_add_field.py index f1e3f3c..ae73720 100644 --- a/nonebot_plugin_tetris_stats/config/migrations/6c3206f90cc3_add_field.py +++ b/nonebot_plugin_tetris_stats/config/migrations/6c3206f90cc3_add_field.py @@ -28,7 +28,7 @@ def upgrade(name: str = '') -> None: return if op.get_bind().dialect.name == 'postgresql': return - from json import dumps, loads + from json import dumps, loads # noqa: PLC0415 Base = automap_base() # noqa: N806 connection = op.get_bind() @@ -54,7 +54,7 @@ def downgrade(name: str = '') -> None: return if op.get_bind().dialect.name == 'postgresql': return - from json import dumps, loads + from json import dumps, loads # noqa: PLC0415 Base = automap_base() # noqa: N806 connection = op.get_bind() diff --git a/nonebot_plugin_tetris_stats/config/migrations/766cc7e75a62_migrate_to_uninfo.py b/nonebot_plugin_tetris_stats/config/migrations/766cc7e75a62_migrate_to_uninfo.py index 021059f..cc0e802 100644 --- a/nonebot_plugin_tetris_stats/config/migrations/766cc7e75a62_migrate_to_uninfo.py +++ b/nonebot_plugin_tetris_stats/config/migrations/766cc7e75a62_migrate_to_uninfo.py @@ -45,7 +45,10 @@ def data_migrate() -> None: return try: - from nonebot_session_to_uninfo import check_tables, get_id_map # type: ignore[import-untyped] + from nonebot_session_to_uninfo import ( # type: ignore[import-untyped] # noqa: PLC0415 + check_tables, + get_id_map, + ) except ImportError as err: msg = '请安装 `nonebot-session-to-uninfo` 以迁移数据' raise ValueError(msg) from err diff --git a/nonebot_plugin_tetris_stats/config/migrations/8a91210ce14d_correct_the_data_in_historicaldata.py b/nonebot_plugin_tetris_stats/config/migrations/8a91210ce14d_correct_the_data_in_historicaldata.py index 9a263ed..7a02c55 100644 --- a/nonebot_plugin_tetris_stats/config/migrations/8a91210ce14d_correct_the_data_in_historicaldata.py +++ b/nonebot_plugin_tetris_stats/config/migrations/8a91210ce14d_correct_the_data_in_historicaldata.py @@ -31,9 +31,9 @@ def upgrade(name: str = '') -> None: # noqa: C901 if op.get_bind().dialect.name == 'postgresql': return - from nonebot.compat import PYDANTIC_V2, type_validate_json - from pydantic import BaseModel, ValidationError - from rich.progress import ( + from nonebot.compat import PYDANTIC_V2, type_validate_json # noqa: PLC0415 + from pydantic import BaseModel, ValidationError # noqa: PLC0415 + from rich.progress import ( # noqa: PLC0415 BarColumn, MofNCompleteColumn, Progress, @@ -60,14 +60,14 @@ def upgrade(name: str = '') -> None: # noqa: C901 logger.info('空表, 跳过') return - from nonebot_plugin_tetris_stats.version import __version__ + from nonebot_plugin_tetris_stats.version import __version__ # noqa: PLC0415 if __version__ != '1.0.3': msg = '本迁移需要1.0.3版本, 请先锁定版本至1.0.3版本再执行本迁移' logger.critical(msg) raise RuntimeError(msg) - from nonebot_plugin_tetris_stats.game_data_processor.schemas import ( # type: ignore[import-untyped] + from nonebot_plugin_tetris_stats.game_data_processor.schemas import ( # type: ignore[import-untyped] # noqa: PLC0415 BaseProcessedData, ) diff --git a/nonebot_plugin_tetris_stats/config/migrations/b7fbdafc339a_add_user_unique_identifier_field_to_.py b/nonebot_plugin_tetris_stats/config/migrations/b7fbdafc339a_add_user_unique_identifier_field_to_.py index 5d0863c..c3544f5 100644 --- a/nonebot_plugin_tetris_stats/config/migrations/b7fbdafc339a_add_user_unique_identifier_field_to_.py +++ b/nonebot_plugin_tetris_stats/config/migrations/b7fbdafc339a_add_user_unique_identifier_field_to_.py @@ -29,9 +29,9 @@ def upgrade(name: str = '') -> None: # noqa: C901 if op.get_bind().dialect.name == 'postgresql': return - from nonebot.compat import type_validate_json - from pydantic import ValidationError - from rich.progress import ( + from nonebot.compat import type_validate_json # noqa: PLC0415 + from pydantic import ValidationError # noqa: PLC0415 + from rich.progress import ( # noqa: PLC0415 BarColumn, MofNCompleteColumn, Progress, @@ -39,9 +39,9 @@ def upgrade(name: str = '') -> None: # noqa: C901 TextColumn, TimeRemainingColumn, ) - from sqlalchemy import select - from sqlalchemy.ext.automap import automap_base - from sqlalchemy.orm import Session + from sqlalchemy import select # noqa: PLC0415 + from sqlalchemy.ext.automap import automap_base # noqa: PLC0415 + from sqlalchemy.orm import Session # noqa: PLC0415 with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op: batch_op.add_column(sa.Column('user_unique_identifier', sa.String(length=32), nullable=True)) @@ -60,13 +60,15 @@ def upgrade(name: str = '') -> None: # noqa: C901 if count == 0: logger.info('空表, 跳过') else: - from nonebot_plugin_tetris_stats.version import __version__ + from nonebot_plugin_tetris_stats.version import __version__ # noqa: PLC0415 if __version__ != '1.0.4': msg = '本迁移需要1.0.4版本, 请先锁定版本至1.0.4版本再执行本迁移' logger.critical(msg) raise RuntimeError(msg) - from nonebot_plugin_tetris_stats.game_data_processor.schemas import BaseUser # type: ignore[import-untyped] + from nonebot_plugin_tetris_stats.game_data_processor.schemas import ( # type: ignore[import-untyped] # noqa: PLC0415 + BaseUser, + ) models: list[type[BaseUser]] = BaseUser.__subclasses__() diff --git a/nonebot_plugin_tetris_stats/games/schemas.py b/nonebot_plugin_tetris_stats/games/schemas.py index e59ef7b..e66b81c 100644 --- a/nonebot_plugin_tetris_stats/games/schemas.py +++ b/nonebot_plugin_tetris_stats/games/schemas.py @@ -22,3 +22,5 @@ class BaseUser(BaseModel, ABC, Generic[T]): @abstractmethod def unique_identifier(self) -> str: raise NotImplementedError + + __hash__ = BaseModel.__hash__ diff --git a/nonebot_plugin_tetris_stats/i18n/__init__.py b/nonebot_plugin_tetris_stats/i18n/__init__.py index f43d64d..ba0077e 100644 --- a/nonebot_plugin_tetris_stats/i18n/__init__.py +++ b/nonebot_plugin_tetris_stats/i18n/__init__.py @@ -1,7 +1,7 @@ # This file is @generated by tarina.lang CLI tool # It is not intended for manual editing. -# ruff: noqa: E402, F401, PLC0414 +# ruff: noqa: E402 from pathlib import Path diff --git a/nonebot_plugin_tetris_stats/utils/render/avatar/draw/__init__.py b/nonebot_plugin_tetris_stats/utils/render/avatar/draw/__init__.py index 92d9637..6d4442b 100644 --- a/nonebot_plugin_tetris_stats/utils/render/avatar/draw/__init__.py +++ b/nonebot_plugin_tetris_stats/utils/render/avatar/draw/__init__.py @@ -43,8 +43,8 @@ class Piece(Enum): ) I5 = ( - (True, True, True, True, True), # fmt: skip - ) + (True, True, True, True, True), + ) # fmt: skip V = ( (True, False, False), diff --git a/tests/tetrio/test_bind.py b/tests/tetrio/test_bind.py index 3224d26..6db763c 100644 --- a/tests/tetrio/test_bind.py +++ b/tests/tetrio/test_bind.py @@ -7,7 +7,7 @@ from tests.fake_event import FakeGroupMessageEvent @pytest.mark.asyncio async def test_invalid_name(app: App) -> None: - from nonebot_plugin_tetris_stats.games import alc + from nonebot_plugin_tetris_stats.games import alc # noqa: PLC0415 raw_message = 'tstats tetrio bind 芜湖' message = Message(raw_message)