From 15d3a33cb8e6c210612c202ed202fc12672ab20c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 04:06:46 +0800 Subject: [PATCH] :arrow_up: auto update by pre-commit hooks (#587) 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.14.14 → v0.15.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.14...v0.15.0) * Fix ASYNC240: Use async file I/O in check_hash (#591) * Initial plan * Fix ASYNC240: Replace synchronous Path.read_text() with async aiofiles operation Co-authored-by: shoucandanghehe <51957264+shoucandanghehe@users.noreply.github.com> * Add explicit UTF-8 encoding to ensure consistent behavior across platforms Co-authored-by: shoucandanghehe <51957264+shoucandanghehe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: shoucandanghehe <51957264+shoucandanghehe@users.noreply.github.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: shoucandanghehe <51957264+shoucandanghehe@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- nonebot_plugin_tetris_stats/utils/templates.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 96c27cb..3003aa2 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.14.14 + rev: v0.15.0 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/nonebot_plugin_tetris_stats/utils/templates.py b/nonebot_plugin_tetris_stats/utils/templates.py index 8d5e4cc..b14bb6e 100644 --- a/nonebot_plugin_tetris_stats/utils/templates.py +++ b/nonebot_plugin_tetris_stats/utils/templates.py @@ -71,7 +71,9 @@ def unzip_templates(zip_path: Path) -> Path: async def check_hash(hash_file_path: Path) -> bool: logger.info('开始校验模板哈希值') - for i in hash_file_path.read_text().splitlines(): + async with aopen(hash_file_path, encoding='utf-8') as f: + hash_content = await f.read() + for i in hash_content.splitlines(): file_sha256, file_relative_path = i.split(maxsplit=1) file_path = hash_file_path.parent / file_relative_path hasher = sha256()