Skip to content

Commit 7648aa1

Browse files
authored
refactor: 使用 TypeIs 替换 TypeGuard (#166)
1 parent 51ed2e4 commit 7648aa1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

alicebot/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Union,
2525
cast,
2626
)
27-
from typing_extensions import ParamSpec, TypeAlias, TypeGuard, override
27+
from typing_extensions import ParamSpec, TypeAlias, TypeIs, override
2828

2929
import anyio
3030
import anyio.to_thread
@@ -78,7 +78,7 @@ def find_spec(
7878
return PathFinder.find_spec(fullname, self.path + list(path), target)
7979

8080

81-
def is_config_class(config_class: Any) -> TypeGuard[type[ConfigModel]]:
81+
def is_config_class(config_class: Any) -> TypeIs[type[ConfigModel]]:
8282
"""判断一个对象是否是配置类。
8383
8484
Args:

packages/alicebot-adapter-telegram/alicebot/adapter/telegram/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import json
99
import uuid
1010
from typing import Any, Optional, TypeVar, Union
11-
from typing_extensions import TypeGuard, override
11+
from typing_extensions import TypeIs, override
1212

1313
import aiohttp
1414
import structlog
@@ -162,7 +162,7 @@ def _format_telegram_api_params(
162162
) -> Union[aiohttp.FormData, dict[str, Any]]:
163163
file_type_adapter: TypeAdapter[InputFile] = TypeAdapter(InputFile)
164164

165-
def is_file(v: Any) -> TypeGuard[InputFile]:
165+
def is_file(v: Any) -> TypeIs[InputFile]:
166166
try:
167167
file_type_adapter.validate_python(v, strict=True)
168168
except ValidationError:

0 commit comments

Comments
 (0)