Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions alicebot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from contextlib import AsyncExitStack
from itertools import chain
from pathlib import Path
from typing import Any, Callable, Optional, Union, overload
from typing import Any, Callable, Optional, Union, cast, overload

import anyio
import structlog
Expand Down Expand Up @@ -366,7 +366,7 @@ def update_config(
try:
default_value = config_class()
except ValidationError:
default_value = ...
default_value = cast("Any", ...)
config_update_dict[config_class.__config_name__] = (
config_class,
default_value,
Expand Down
6 changes: 3 additions & 3 deletions alicebot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class BotConfig(ConfigModel):
"""

event_queue_size: int = Field(default=0, ge=0)
plugins: set[str] = Field(default_factory=set)
plugin_dirs: set[DirectoryPath] = Field(default_factory=set)
adapters: set[str] = Field(default_factory=set)
plugins: set[str] = Field(default_factory=set[str])
plugin_dirs: set[DirectoryPath] = Field(default_factory=set[DirectoryPath])
adapters: set[str] = Field(default_factory=set[str])
log: Optional[LogConfig] = None


Expand Down
12 changes: 6 additions & 6 deletions alicebot/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ async def solve_dependencies(
raise TypeError("can not solve dependent")
sub_dependent.dependency = dependent_ann
values[name] = await solve_dependencies(
cast(Dependency[_T], sub_dependent.dependency),
cast("Dependency[_T]", sub_dependent.dependency),
use_cache=sub_dependent.use_cache,
stack=stack,
dependency_cache=dependency_cache,
)
depend_obj = cast(
Union[_T, AbstractAsyncContextManager[_T], AbstractContextManager[_T]],
"Union[_T, AbstractAsyncContextManager[_T], AbstractContextManager[_T]]",
dependent.__new__(dependent), # type: ignore
)
for key, value in values.items():
Expand All @@ -124,22 +124,22 @@ async def solve_dependencies(

if isinstance(depend_obj, AbstractAsyncContextManager):
depend = await stack.enter_async_context(
cast(AbstractAsyncContextManager[_T], depend_obj)
cast("AbstractAsyncContextManager[_T]", depend_obj)
)
elif isinstance(depend_obj, AbstractContextManager):
depend = await stack.enter_async_context(
sync_ctx_manager_wrapper(cast(AbstractContextManager[_T], depend_obj))
sync_ctx_manager_wrapper(cast("AbstractContextManager[_T]", depend_obj))
)
else:
depend = depend_obj
elif inspect.isasyncgenfunction(dependent):
# type of dependent is Callable[[], AsyncGenerator[T, None]]
cm = asynccontextmanager(dependent)()
depend = cast(_T, await stack.enter_async_context(cm))
depend = cast("_T", await stack.enter_async_context(cm))
elif inspect.isgeneratorfunction(dependent):
# type of dependent is Callable[[], Generator[T, None, None]]
cm = sync_ctx_manager_wrapper(contextmanager(dependent)())
depend = cast(_T, await stack.enter_async_context(cm))
depend = cast("_T", await stack.enter_async_context(cm))
else:
raise TypeError("dependent is not a class or generator function")

Expand Down
2 changes: 1 addition & 1 deletion alicebot/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class MessageSegment(ABC, BaseModel, Mapping[str, Any], Generic[MessageT]):
"""

type: str
data: dict[str, Any] = Field(default_factory=dict)
data: dict[str, Any] = Field(default_factory=dict[str, Any])

@classmethod
@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion alicebot/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init_subclass__(
if inspect.isclass(origin_class) and issubclass(origin_class, Plugin):
try:
_event_t, state_t, config_t = cast(
tuple[EventT, StateT, ConfigT], get_args(orig_base)
"tuple[EventT, StateT, ConfigT]", get_args(orig_base)
)
except ValueError: # pragma: no cover
continue
Expand Down
4 changes: 2 additions & 2 deletions alicebot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_classes_from_module(module: ModuleType, super_class: _TypeT) -> list[_Ty
and ABC not in module_attr.__bases__
and not inspect.isabstract(module_attr)
):
classes.append(cast(_TypeT, module_attr))
classes.append(cast("_TypeT", module_attr))
return classes


Expand Down Expand Up @@ -244,7 +244,7 @@ def wrap_get_func(
if func is None:
func = sync_func_wrapper(lambda _: True)
elif not inspect.iscoroutinefunction(func):
func = sync_func_wrapper(cast(Callable[[EventT], bool], func))
func = sync_func_wrapper(cast("Callable[[EventT], bool]", func))

async def _func(event: EventT) -> bool:
return (
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,24 @@
},
"dependencies": {
"@iconify-json/mdi": "^1.2.3",
"unocss": "^65.4.3",
"unocss": "^66.0.0",
"vitepress": "^1.6.3",
"vue": "^3.5.13"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@types/node": "^22.13.1",
"@unocss/eslint-config": "^65.4.3",
"@eslint/js": "^9.25.0",
"@types/node": "^22.14.1",
"@unocss/eslint-config": "^66.0.0",
"conventional-changelog-cli": "^5.0.0",
"eslint": "^9.19.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-vue": "^9.32.0",
"globals": "^15.14.0",
"eslint": "^9.25.0",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-vue": "^10.0.0",
"globals": "^16.0.0",
"markdownlint-cli2": "^0.17.2",
"prettier": "^3.4.2",
"pyright": "^1.1.393",
"typescript-eslint": "^8.23.0",
"prettier": "^3.5.3",
"pyright": "^1.1.399",
"typescript-eslint": "^8.30.1",
"vue-eslint-parser": "^10.1.3",
"zhlint": "^0.8.2"
},
"pnpm": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class Config(ConfigModel):
"""

__config_name__ = "apscheduler"
scheduler_config: dict[str, Any] = Field(default_factory=dict)
scheduler_config: dict[str, Any] = Field(default_factory=dict[str, Any])
10 changes: 5 additions & 5 deletions packages/alicebot-adapter-telegram/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ class MethodDescription(BaseModel):
name: str
href: str
description: Optional[list[str]] = None
returns: list[str] = Field(default_factory=list)
fields: list[FieldDescription] = Field(default_factory=list)
returns: list[str] = Field(default_factory=list[str])
fields: list[FieldDescription] = Field(default_factory=list[FieldDescription])

def to_api_method(self) -> str:
"""生成 API 方法字符串。"""
Expand Down Expand Up @@ -225,9 +225,9 @@ class TypeDescription(BaseModel):
name: str
href: str
description: Optional[list[str]] = None
fields: list[FieldDescription] = Field(default_factory=list)
subtypes: list[str] = Field(default_factory=list)
subtype_of: list[str] = Field(default_factory=list)
fields: list[FieldDescription] = Field(default_factory=list[FieldDescription])
subtypes: list[str] = Field(default_factory=list[str])
subtype_of: list[str] = Field(default_factory=list[str])

def to_model(self) -> str:
"""生成模型代码。"""
Expand Down
Loading
Loading