From ec7db4574f04751e14372adaa414dea3249836f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:41:10 +0000 Subject: [PATCH 1/2] :arrow_up: auto update by pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.3 → v0.9.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.3...v0.9.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 17e12c5..b42d241 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.8.3 + rev: v0.9.2 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From b7a49df4f580dc1078568150e3ea6213013cd245 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:41:16 +0000 Subject: [PATCH 2/2] :rotating_light: auto fix by pre-commit hooks --- nonebot_plugin_tetris_stats/games/tetrio/query/v2.py | 4 ++-- nonebot_plugin_tetris_stats/games/tos/query.py | 4 ++-- nonebot_plugin_tetris_stats/utils/limit.py | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nonebot_plugin_tetris_stats/games/tetrio/query/v2.py b/nonebot_plugin_tetris_stats/games/tetrio/query/v2.py index fe3bf7c..1577072 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/query/v2.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/query/v2.py @@ -43,9 +43,9 @@ async def make_query_image_v2(player: Player) -> bytes: play_time: str | None if (game_time := handling_special_value(user_info.data.gametime)) is not None: if game_time // 3600 > 0: - play_time = f'{game_time//3600:.0f}h {game_time % 3600 // 60:.0f}m {game_time % 60:.0f}s' + play_time = f'{game_time // 3600:.0f}h {game_time % 3600 // 60:.0f}m {game_time % 60:.0f}s' elif game_time // 60 > 0: - play_time = f'{game_time//60:.0f}m {game_time % 60:.0f}s' + play_time = f'{game_time // 60:.0f}m {game_time % 60:.0f}s' else: play_time = f'{game_time:.0f}s' else: diff --git a/nonebot_plugin_tetris_stats/games/tos/query.py b/nonebot_plugin_tetris_stats/games/tos/query.py index c57e28c..cef66b3 100644 --- a/nonebot_plugin_tetris_stats/games/tos/query.py +++ b/nonebot_plugin_tetris_stats/games/tos/query.py @@ -258,7 +258,7 @@ def make_query_text(user_info: UserInfoSuccess, game_data: GameData | None) -> U if user_data.ranked_games == '0': message += '暂无段位统计数据' else: - message += f', 段位分 {round(float(user_data.rating_now),2)}±{round(float(user_data.rd_now),2)} ({round(float(user_data.vol_now),2)}) ' + message += f', 段位分 {round(float(user_data.rating_now), 2)}±{round(float(user_data.rd_now), 2)} ({round(float(user_data.vol_now), 2)}) ' if game_data is None: message += ', 暂无游戏数据' else: @@ -266,7 +266,7 @@ def make_query_text(user_info: UserInfoSuccess, game_data: GameData | None) -> U message += f"\nL'PM: {game_data.metrics.lpm} ( {game_data.metrics.pps} pps )" message += f'\nAPM: {game_data.metrics.apm} ( x{game_data.metrics.apl} )' message += f'\nADPM: {game_data.metrics.adpm} ( x{game_data.metrics.adpl} ) ( {game_data.metrics.vs}vs )' - message += f'\n40L: {float(user_data.pb_sprint)/1000:.2f}s' if user_data.pb_sprint != '2147483647' else '' + message += f'\n40L: {float(user_data.pb_sprint) / 1000:.2f}s' if user_data.pb_sprint != '2147483647' else '' message += f'\nMarathon: {user_data.pb_marathon}' if user_data.pb_marathon != '0' else '' message += f'\nChallenge: {user_data.pb_challenge}' if user_data.pb_challenge != '0' else '' return UniMessage(message) diff --git a/nonebot_plugin_tetris_stats/utils/limit.py b/nonebot_plugin_tetris_stats/utils/limit.py index 710d7ed..2c64c37 100644 --- a/nonebot_plugin_tetris_stats/utils/limit.py +++ b/nonebot_plugin_tetris_stats/utils/limit.py @@ -23,7 +23,9 @@ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: nonlocal last_call async with lock: if (diff := (time() - last_call)) < limit_seconds: - logger.debug(f'func: {func.__name__} trigger limit, wait {(limit_time:=limit_seconds-diff):.3f}s') + logger.debug( + f'func: {func.__name__} trigger limit, wait {(limit_time := limit_seconds - diff):.3f}s' + ) await sleep(limit_time) last_call = time() return await func(*args, **kwargs)