diff --git a/pyproject.toml b/pyproject.toml index ecffa362a..f429a9f40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,6 +73,9 @@ dependencies = [ "openai-agents>=0.12.5", "fastapi>=0.135.1", ] +[project.urls] +Homepage = "https://astrbot.app" +Repository = "https://github.com/AstrBotDevs/AstrBot" [project.scripts] astrbot = "astrbot:cli" astrbot-rs = "astrbot:cli_rs" @@ -90,8 +93,7 @@ dev = [ -[project.urls] -Repository = "https://github.com/AstrBotDevs/AstrBot" + [tool.ruff] exclude = [ @@ -134,13 +136,18 @@ ignore = [ ] [tool.pyright] +stubPath = "types" typeCheckingMode = "basic" -pythonVersion = "3.10" +pythonVersion = "3.12" reportMissingTypeStubs = false reportMissingImports = false include = ["astrbot"] exclude = ["dashboard", "node_modules", "dist", "data", "tests", "tests/**", "**/tests/**"] +[tool.mypy] +plugins = ["pydantic.mypy"] +mypy_path = "types" + [tool.hatch.metadata] allow-direct-references = true diff --git a/types/aip.pyi b/types/aip.pyi new file mode 100644 index 000000000..2ee09e3f0 --- /dev/null +++ b/types/aip.pyi @@ -0,0 +1,3 @@ +class AipContentCensor: + def __init__(self, appid: str, ak: str, sk: str) -> None: ... + def textCensorUserDefined(self, content: str) -> dict[str, object]: ... diff --git a/types/deprecated.pyi b/types/deprecated.pyi new file mode 100644 index 000000000..10f10fc99 --- /dev/null +++ b/types/deprecated.pyi @@ -0,0 +1,6 @@ +from collections.abc import Callable +from typing import TypeVar + +_F = TypeVar("_F", bound=Callable[..., object]) + +def deprecated(*args: object, **kwargs: object) -> Callable[[_F], _F]: ... diff --git a/typings/faiss/__init__.pyi b/types/faiss/__init__.pyi similarity index 100% rename from typings/faiss/__init__.pyi rename to types/faiss/__init__.pyi diff --git a/types/jsonschema.pyi b/types/jsonschema.pyi new file mode 100644 index 000000000..5ac6d166c --- /dev/null +++ b/types/jsonschema.pyi @@ -0,0 +1,6 @@ +from typing import ClassVar + +class Draft202012Validator: + META_SCHEMA: ClassVar[dict[str, object]] + +def validate(instance: object, schema: object) -> None: ... diff --git a/types/pilk.pyi b/types/pilk.pyi new file mode 100644 index 000000000..3701f92c0 --- /dev/null +++ b/types/pilk.pyi @@ -0,0 +1,7 @@ +def encode( + input_path: str, + output_path: str, + *, + pcm_rate: int, + tencent: bool = ..., +) -> float: ... diff --git a/types/psutil.pyi b/types/psutil.pyi new file mode 100644 index 000000000..53eecbdda --- /dev/null +++ b/types/psutil.pyi @@ -0,0 +1,39 @@ +from collections.abc import Iterable + +class NoSuchProcess(Exception): ... +class AccessDenied(Exception): ... +class ZombieProcess(Exception): ... +class TimeoutExpired(Exception): ... + +class _Addr: + family: int + address: str + +class _ConnectionAddress: + port: int + +class _Connection: + laddr: _ConnectionAddress + +class _MemoryInfo: + rss: int + +class _VirtualMemory: + total: int + +class Process: + pid: int + info: dict[str, object] + + def __init__(self, pid: int | None = ...) -> None: ... + def children(self, recursive: bool = ...) -> list[Process]: ... + def terminate(self) -> None: ... + def wait(self, timeout: float | None = ...) -> object: ... + def kill(self) -> None: ... + def memory_info(self) -> _MemoryInfo: ... + def net_connections(self) -> list[_Connection]: ... + +def net_if_addrs() -> dict[str, list[_Addr]]: ... +def process_iter(attrs: Iterable[str] | None = ...) -> Iterable[Process]: ... +def cpu_percent(interval: float | None = ...) -> float: ... +def virtual_memory() -> _VirtualMemory: ... diff --git a/types/pyffmpeg.pyi b/types/pyffmpeg.pyi new file mode 100644 index 000000000..a314a5ff8 --- /dev/null +++ b/types/pyffmpeg.pyi @@ -0,0 +1,2 @@ +class FFmpeg: + def convert(self, *, input_file: str, output_file: str) -> None: ... diff --git a/types/pysilk.pyi b/types/pysilk.pyi new file mode 100644 index 000000000..37dd4efc8 --- /dev/null +++ b/types/pysilk.pyi @@ -0,0 +1,3 @@ +from io import BytesIO + +def decode(input_io: BytesIO, output_io: BytesIO, sample_rate: int) -> None: ... diff --git a/types/readability.pyi b/types/readability.pyi new file mode 100644 index 000000000..b46e5ab5f --- /dev/null +++ b/types/readability.pyi @@ -0,0 +1,22 @@ +from typing import Any + +class Document: + def __init__( + self, + input: str | Any, + positive_keywords: str | list[str] | None = None, + negative_keywords: str | list[str] | None = None, + url: str | None = None, + min_text_length: int = 25, + retry_length: int = 250, + xpath: bool = False, + handle_failures: str = "discard", + ) -> None: ... + def content(self) -> str: ... + def title(self) -> str: ... + def author(self) -> str: ... + def short_title(self) -> str: ... + def summary( + self, html_partial: bool = False, keep_all_images: bool = False + ) -> str: ... + def get_clean_html(self) -> str: ... diff --git a/types/yaml.pyi b/types/yaml.pyi new file mode 100644 index 000000000..f877783ea --- /dev/null +++ b/types/yaml.pyi @@ -0,0 +1,11 @@ +from typing import TextIO + +class YAMLError(Exception): ... + +def safe_load(stream: str | TextIO) -> object: ... +def dump( + data: object, + stream: TextIO | None = ..., + *args: object, + **kwargs: object, +) -> str | None: ...