From 05d8a22a2462860a2b16ab63d6754276be4cc02e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 22:54:45 +0000 Subject: [PATCH 1/4] :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.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.3...v0.9.6) --- .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..04c3ef9 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.6 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] From 9a924a42a829254fda91e0dbcc567a1b722da0de Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 22:54:51 +0000 Subject: [PATCH 2/4] :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) From 9346505701d1e397a9fd0b7d9dc5e45aa50ea7ef Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Thu, 13 Feb 2025 04:13:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=20typing=20=E4=B8=BA=20typedefs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_tetris_stats/db/__init__.py | 2 +- nonebot_plugin_tetris_stats/db/models.py | 2 +- nonebot_plugin_tetris_stats/games/schemas.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/api/models.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/api/player.py | 2 +- .../games/tetrio/api/schemas/base/__init__.py | 2 +- .../games/tetrio/api/schemas/leaderboards/__init__.py | 2 +- .../games/tetrio/api/schemas/leaderboards/by.py | 2 +- .../games/tetrio/api/schemas/summaries/league.py | 2 +- .../games/tetrio/api/{typing.py => typedefs.py} | 0 nonebot_plugin_tetris_stats/games/tetrio/config.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/constant.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/models.py | 4 ++-- nonebot_plugin_tetris_stats/games/tetrio/query/__init__.py | 4 ++-- nonebot_plugin_tetris_stats/games/tetrio/rank/__init__.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/rank/all.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/rank/detail.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/record/__init__.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/record/blitz.py | 2 +- nonebot_plugin_tetris_stats/games/tetrio/record/sprint.py | 2 +- .../games/tetrio/{typing.py => typedefs.py} | 0 nonebot_plugin_tetris_stats/games/top/__init__.py | 2 +- nonebot_plugin_tetris_stats/games/top/query.py | 2 +- nonebot_plugin_tetris_stats/games/tos/__init__.py | 2 +- nonebot_plugin_tetris_stats/games/tos/query.py | 2 +- nonebot_plugin_tetris_stats/utils/metrics.py | 2 +- nonebot_plugin_tetris_stats/utils/render/schemas/base.py | 2 +- .../utils/render/schemas/tetrio/rank/detail.py | 2 +- .../utils/render/schemas/tetrio/rank/v1.py | 2 +- .../utils/render/schemas/tetrio/rank/v2.py | 2 +- .../utils/render/schemas/tetrio/user/base.py | 2 +- .../utils/render/schemas/tetrio/user/info_v1.py | 4 ++-- .../utils/render/schemas/tetrio/user/info_v2.py | 4 ++-- .../utils/render/schemas/tetrio/user/list_v2.py | 4 ++-- nonebot_plugin_tetris_stats/utils/render/schemas/top_info.py | 2 +- nonebot_plugin_tetris_stats/utils/render/schemas/tos_info.py | 2 +- nonebot_plugin_tetris_stats/utils/{typing.py => typedefs.py} | 0 37 files changed, 39 insertions(+), 39 deletions(-) rename nonebot_plugin_tetris_stats/games/tetrio/api/{typing.py => typedefs.py} (100%) rename nonebot_plugin_tetris_stats/games/tetrio/{typing.py => typedefs.py} (100%) rename nonebot_plugin_tetris_stats/utils/{typing.py => typedefs.py} (100%) diff --git a/nonebot_plugin_tetris_stats/db/__init__.py b/nonebot_plugin_tetris_stats/db/__init__.py index 17a4ea7..eb989ab 100644 --- a/nonebot_plugin_tetris_stats/db/__init__.py +++ b/nonebot_plugin_tetris_stats/db/__init__.py @@ -11,7 +11,7 @@ from nonebot_plugin_user import User from sqlalchemy import select -from ..utils.typing import AllCommandType, BaseCommandType, GameType, TETRIOCommandType +from ..utils.typedefs import AllCommandType, BaseCommandType, GameType, TETRIOCommandType from .models import Bind, TriggerHistoricalData UTC = timezone.utc diff --git a/nonebot_plugin_tetris_stats/db/models.py b/nonebot_plugin_tetris_stats/db/models.py index f7c8991..661c89b 100644 --- a/nonebot_plugin_tetris_stats/db/models.py +++ b/nonebot_plugin_tetris_stats/db/models.py @@ -9,7 +9,7 @@ from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column from typing_extensions import override -from ..utils.typing import AllCommandType, GameType +from ..utils.typedefs import AllCommandType, GameType class PydanticType(TypeDecorator): diff --git a/nonebot_plugin_tetris_stats/games/schemas.py b/nonebot_plugin_tetris_stats/games/schemas.py index 7fdb2bd..e59ef7b 100644 --- a/nonebot_plugin_tetris_stats/games/schemas.py +++ b/nonebot_plugin_tetris_stats/games/schemas.py @@ -3,7 +3,7 @@ from pydantic import BaseModel -from ..utils.typing import GameType +from ..utils.typedefs import GameType T = TypeVar('T', bound=GameType) diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/models.py b/nonebot_plugin_tetris_stats/games/tetrio/api/models.py index 8bc9ee4..64a3c54 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/api/models.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/api/models.py @@ -7,7 +7,7 @@ from ....db.models import PydanticType from .schemas.base import SuccessModel -from .typing import Records, Summaries +from .typedefs import Records, Summaries class TETRIOHistoricalData(MappedAsDataclass, Model): diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/player.py b/nonebot_plugin_tetris_stats/games/tetrio/api/player.py index 0c19990..dbe6f9e 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/api/player.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/api/player.py @@ -27,7 +27,7 @@ from .schemas.summaries.league import LeagueSuccessModel from .schemas.user import User from .schemas.user_info import UserInfo, UserInfoSuccess -from .typing import Records, Summaries +from .typedefs import Records, Summaries class RecordModeType(str, Enum): diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/base/__init__.py b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/base/__init__.py index 71ebaca..74d04af 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/base/__init__.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/base/__init__.py @@ -3,7 +3,7 @@ from pydantic import BaseModel, Field -from ...typing import Prisecter +from ...typedefs import Prisecter class AggregateStats(BaseModel): diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py index e37caac..5f41326 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/__init__.py @@ -3,7 +3,7 @@ from nonebot.compat import PYDANTIC_V2 from pydantic import BaseModel, Field -from ...typing import Prisecter +from ...typedefs import Prisecter class Parameter(BaseModel): diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/by.py b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/by.py index d7c4fd6..e30031a 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/by.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/leaderboards/by.py @@ -3,7 +3,7 @@ from pydantic import BaseModel, Field -from ...typing import Rank, ValidRank +from ...typedefs import Rank, ValidRank from ..base import ArCounts, FailedModel, P, SuccessModel diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/summaries/league.py b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/summaries/league.py index e6cfc61..8e97dba 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/summaries/league.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/api/schemas/summaries/league.py @@ -3,7 +3,7 @@ from nonebot.compat import PYDANTIC_V2 from pydantic import BaseModel, Field -from ...typing import Rank, S1Rank, S1ValidRank +from ...typedefs import Rank, S1Rank, S1ValidRank from ..base import SuccessModel if PYDANTIC_V2: diff --git a/nonebot_plugin_tetris_stats/games/tetrio/api/typing.py b/nonebot_plugin_tetris_stats/games/tetrio/api/typedefs.py similarity index 100% rename from nonebot_plugin_tetris_stats/games/tetrio/api/typing.py rename to nonebot_plugin_tetris_stats/games/tetrio/api/typedefs.py diff --git a/nonebot_plugin_tetris_stats/games/tetrio/config.py b/nonebot_plugin_tetris_stats/games/tetrio/config.py index ff062f1..b89160c 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/config.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/config.py @@ -11,7 +11,7 @@ from . import alc, command from .constant import GAME_TYPE from .models import TETRIOUserConfig -from .typing import Template +from .typedefs import Template command.add( Subcommand( diff --git a/nonebot_plugin_tetris_stats/games/tetrio/constant.py b/nonebot_plugin_tetris_stats/games/tetrio/constant.py index e7b0297..7195af4 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/constant.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/constant.py @@ -3,7 +3,7 @@ from yarl import URL -from .api.typing import ValidRank +from .api.typedefs import ValidRank GAME_TYPE: Literal['IO'] = 'IO' diff --git a/nonebot_plugin_tetris_stats/games/tetrio/models.py b/nonebot_plugin_tetris_stats/games/tetrio/models.py index 4f959df..34ed4f4 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/models.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/models.py @@ -7,8 +7,8 @@ from ...db.models import PydanticType from .api.schemas.leaderboards.by import BySuccessModel, Entry -from .api.typing import ValidRank -from .typing import Template +from .api.typedefs import ValidRank +from .typedefs import Template class TETRIOUserConfig(MappedAsDataclass, Model): diff --git a/nonebot_plugin_tetris_stats/games/tetrio/query/__init__.py b/nonebot_plugin_tetris_stats/games/tetrio/query/__init__.py index e7a6963..ea93184 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/query/__init__.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/query/__init__.py @@ -16,13 +16,13 @@ from ....db import query_bind_info, trigger from ....i18n import Lang from ....utils.exception import FallbackError -from ....utils.typing import Me +from ....utils.typedefs import Me from ... import add_block_handlers, alc from .. import command, get_player from ..api import Player from ..constant import GAME_TYPE from ..models import TETRIOUserConfig -from ..typing import Template +from ..typedefs import Template from .v1 import make_query_image_v1 from .v2 import make_query_image_v2 diff --git a/nonebot_plugin_tetris_stats/games/tetrio/rank/__init__.py b/nonebot_plugin_tetris_stats/games/tetrio/rank/__init__.py index bca8705..53a06c6 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/rank/__init__.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/rank/__init__.py @@ -25,7 +25,7 @@ if TYPE_CHECKING: from ..api.schemas.leaderboards.by import BySuccessModel - from ..api.typing import Rank + from ..api.typedefs import Rank UTC = timezone.utc diff --git a/nonebot_plugin_tetris_stats/games/tetrio/rank/all.py b/nonebot_plugin_tetris_stats/games/tetrio/rank/all.py index 7baacb6..b9a6db8 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/rank/all.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/rank/all.py @@ -21,7 +21,7 @@ from .. import alc from ..constant import GAME_TYPE from ..models import TETRIOLeagueStats -from ..typing import Template +from ..typedefs import Template from . import command command.add( diff --git a/nonebot_plugin_tetris_stats/games/tetrio/rank/detail.py b/nonebot_plugin_tetris_stats/games/tetrio/rank/detail.py index 17287a2..90b7f05 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/rank/detail.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/rank/detail.py @@ -17,7 +17,7 @@ from ....utils.render.schemas.tetrio.rank.detail import Data, SpecialData from ....utils.screenshot import screenshot from .. import alc -from ..api.typing import ValidRank +from ..api.typedefs import ValidRank from ..constant import GAME_TYPE from ..models import TETRIOLeagueStats from . import command diff --git a/nonebot_plugin_tetris_stats/games/tetrio/record/__init__.py b/nonebot_plugin_tetris_stats/games/tetrio/record/__init__.py index d9c81de..c61b3b2 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/record/__init__.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/record/__init__.py @@ -1,7 +1,7 @@ from arclet.alconna import Arg, ArgFlag from nonebot_plugin_alconna import Args, At, Subcommand -from ....utils.typing import Me +from ....utils.typedefs import Me from .. import command as base_command from .. import get_player diff --git a/nonebot_plugin_tetris_stats/games/tetrio/record/blitz.py b/nonebot_plugin_tetris_stats/games/tetrio/record/blitz.py index 2974cbf..fbd8200 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/record/blitz.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/record/blitz.py @@ -22,7 +22,7 @@ from ....utils.render.schemas.tetrio.record.base import Finesse, Max, Mini, Tspins, User from ....utils.render.schemas.tetrio.record.blitz import Record, Statistic from ....utils.screenshot import screenshot -from ....utils.typing import Me +from ....utils.typedefs import Me from .. import alc from ..api.player import Player from ..constant import GAME_TYPE diff --git a/nonebot_plugin_tetris_stats/games/tetrio/record/sprint.py b/nonebot_plugin_tetris_stats/games/tetrio/record/sprint.py index f13cb07..fd98b70 100644 --- a/nonebot_plugin_tetris_stats/games/tetrio/record/sprint.py +++ b/nonebot_plugin_tetris_stats/games/tetrio/record/sprint.py @@ -22,7 +22,7 @@ from ....utils.render.schemas.tetrio.record.base import Finesse, Max, Mini, Statistic, Tspins, User from ....utils.render.schemas.tetrio.record.sprint import Record from ....utils.screenshot import screenshot -from ....utils.typing import Me +from ....utils.typedefs import Me from .. import alc from ..api.player import Player from ..constant import GAME_TYPE diff --git a/nonebot_plugin_tetris_stats/games/tetrio/typing.py b/nonebot_plugin_tetris_stats/games/tetrio/typedefs.py similarity index 100% rename from nonebot_plugin_tetris_stats/games/tetrio/typing.py rename to nonebot_plugin_tetris_stats/games/tetrio/typedefs.py diff --git a/nonebot_plugin_tetris_stats/games/top/__init__.py b/nonebot_plugin_tetris_stats/games/top/__init__.py index 8f84fe1..aa535dc 100644 --- a/nonebot_plugin_tetris_stats/games/top/__init__.py +++ b/nonebot_plugin_tetris_stats/games/top/__init__.py @@ -2,7 +2,7 @@ from nonebot_plugin_alconna import Args, At, Subcommand from ...utils.exception import MessageFormatError -from ...utils.typing import Me +from ...utils.typedefs import Me from .. import add_block_handlers, alc, command from .api import Player from .constant import USER_NAME diff --git a/nonebot_plugin_tetris_stats/games/top/query.py b/nonebot_plugin_tetris_stats/games/top/query.py index d8fb903..b7bd06c 100644 --- a/nonebot_plugin_tetris_stats/games/top/query.py +++ b/nonebot_plugin_tetris_stats/games/top/query.py @@ -18,7 +18,7 @@ from ...utils.render.schemas.top_info import Data as InfoData from ...utils.render.schemas.top_info import Info from ...utils.screenshot import screenshot -from ...utils.typing import Me +from ...utils.typedefs import Me from . import alc from .api import Player from .api.schemas.user_profile import Data, UserProfile diff --git a/nonebot_plugin_tetris_stats/games/tos/__init__.py b/nonebot_plugin_tetris_stats/games/tos/__init__.py index 359fd35..25cf786 100644 --- a/nonebot_plugin_tetris_stats/games/tos/__init__.py +++ b/nonebot_plugin_tetris_stats/games/tos/__init__.py @@ -2,7 +2,7 @@ from nonebot_plugin_alconna import Args, At, Subcommand from ...utils.exception import MessageFormatError -from ...utils.typing import Me +from ...utils.typedefs import Me from .. import add_block_handlers, alc, command from .api import Player from .constant import USER_NAME diff --git a/nonebot_plugin_tetris_stats/games/tos/query.py b/nonebot_plugin_tetris_stats/games/tos/query.py index cef66b3..04bfce4 100644 --- a/nonebot_plugin_tetris_stats/games/tos/query.py +++ b/nonebot_plugin_tetris_stats/games/tos/query.py @@ -24,7 +24,7 @@ from ...utils.render.schemas.base import People, Ranking from ...utils.render.schemas.tos_info import Info, Multiplayer, Radar from ...utils.screenshot import screenshot -from ...utils.typing import Me, Number +from ...utils.typedefs import Me, Number from . import alc from .api import Player from .api.schemas.user_info import UserInfoSuccess diff --git a/nonebot_plugin_tetris_stats/utils/metrics.py b/nonebot_plugin_tetris_stats/utils/metrics.py index 9a9db06..0b8dfac 100644 --- a/nonebot_plugin_tetris_stats/utils/metrics.py +++ b/nonebot_plugin_tetris_stats/utils/metrics.py @@ -1,6 +1,6 @@ from typing import overload -from .typing import Number +from .typedefs import Number class TetrisMetricsBaseWithPPS: diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/base.py b/nonebot_plugin_tetris_stats/utils/render/schemas/base.py index 37db381..bd17d19 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/base.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/base.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from ...typing import Number +from ...typedefs import Number class Avatar(BaseModel): diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/detail.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/detail.py index 0f7a2d5..0cd4dc0 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/detail.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/detail.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from ......games.tetrio.api.typing import ValidRank +from ......games.tetrio.api.typedefs import ValidRank class SpecialData(BaseModel): diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v1.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v1.py index 25ab69d..d8ea374 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v1.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v1.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from ......games.tetrio.api.typing import ValidRank +from ......games.tetrio.api.typedefs import ValidRank class ItemData(BaseModel): diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v2.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v2.py index df8c2ac..2eb7f51 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v2.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/rank/v2.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from ......games.tetrio.api.typing import ValidRank +from ......games.tetrio.api.typedefs import ValidRank class AverageData(BaseModel): diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/base.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/base.py index 8023374..01ca854 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/base.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/base.py @@ -2,7 +2,7 @@ from pydantic import BaseModel -from .....typing import Number +from .....typedefs import Number class TetraLeagueHistoryData(BaseModel): diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v1.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v1.py index 0b73e32..10325e4 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v1.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v1.py @@ -1,7 +1,7 @@ from pydantic import BaseModel -from ......games.tetrio.api.typing import Rank -from .....typing import Number +from ......games.tetrio.api.typedefs import Rank +from .....typedefs import Number from ...base import People, Ranking from .base import TetraLeagueHistoryData diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v2.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v2.py index f369b9c..08ba837 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v2.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/info_v2.py @@ -3,8 +3,8 @@ from pydantic import BaseModel -from ......games.tetrio.api.typing import Rank -from .....typing import Number +from ......games.tetrio.api.typedefs import Rank +from .....typedefs import Number from ...base import Avatar from .base import TetraLeagueHistoryData diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/list_v2.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/list_v2.py index 2077b4d..75997c5 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/list_v2.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/user/list_v2.py @@ -2,8 +2,8 @@ from pydantic import BaseModel -from ......games.tetrio.api.typing import Rank -from .....typing import Number +from ......games.tetrio.api.typedefs import Rank +from .....typedefs import Number from ...base import Avatar diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/top_info.py b/nonebot_plugin_tetris_stats/utils/render/schemas/top_info.py index ee94a2e..91fbf39 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/top_info.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/top_info.py @@ -1,6 +1,6 @@ from pydantic import BaseModel -from ...typing import Number +from ...typedefs import Number from .base import People diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tos_info.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tos_info.py index cd68e8e..8950120 100644 --- a/nonebot_plugin_tetris_stats/utils/render/schemas/tos_info.py +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tos_info.py @@ -1,6 +1,6 @@ from pydantic import BaseModel, Field -from ...typing import Number +from ...typedefs import Number from .base import People, Ranking diff --git a/nonebot_plugin_tetris_stats/utils/typing.py b/nonebot_plugin_tetris_stats/utils/typedefs.py similarity index 100% rename from nonebot_plugin_tetris_stats/utils/typing.py rename to nonebot_plugin_tetris_stats/utils/typedefs.py From 1e0589e538952bc99577a25e159d2952e7f53847 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Thu, 13 Feb 2025 04:15:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E4=BD=BF=E7=94=A8=20A?= =?UTF-8?q?nnotated=20=E4=BB=A3=E6=9B=BF=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_tetris_stats/utils/host.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nonebot_plugin_tetris_stats/utils/host.py b/nonebot_plugin_tetris_stats/utils/host.py index 572edbc..f0cadce 100644 --- a/nonebot_plugin_tetris_stats/utils/host.py +++ b/nonebot_plugin_tetris_stats/utils/host.py @@ -2,7 +2,7 @@ from hashlib import sha256 from ipaddress import IPv4Address, IPv6Address from pathlib import Path as FilePath -from typing import TYPE_CHECKING, ClassVar, Literal +from typing import TYPE_CHECKING, Annotated, ClassVar, Literal from aiofiles import open as aopen from fastapi import BackgroundTasks, FastAPI, Path, status @@ -69,9 +69,9 @@ def _(page_hash: str) -> HTMLResponse: @app.get('/host/resource/tetrio/{resource_type}/{user_id}', status_code=status.HTTP_200_OK) async def _( resource_type: Literal['avatars', 'banners'], + user_id: Annotated[str, Path(regex=r'^[a-f0-9]{24}$')], revision: int, background_tasks: BackgroundTasks, - user_id: str = Path(regex=r'^[a-f0-9]{24}$'), ) -> Response: if not (path := CACHE_PATH / 'tetrio' / resource_type / f'{user_id}_{revision}.png').exists(): image = img_to_png(