mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
chore: add type stubs and update pyproject.toml configuration
- Add type stubs for external packages (faiss, psutil, readability, etc.) - Move typings to types/ directory - Update pyproject.toml with mypy plugin configuration - Add project URLs (Homepage, Repository) - Update python version to 3.12 in pyright config
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
3
types/aip.pyi
Normal file
3
types/aip.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
class AipContentCensor:
|
||||
def __init__(self, appid: str, ak: str, sk: str) -> None: ...
|
||||
def textCensorUserDefined(self, content: str) -> dict[str, object]: ...
|
||||
6
types/deprecated.pyi
Normal file
6
types/deprecated.pyi
Normal file
@@ -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]: ...
|
||||
6
types/jsonschema.pyi
Normal file
6
types/jsonschema.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
from typing import ClassVar
|
||||
|
||||
class Draft202012Validator:
|
||||
META_SCHEMA: ClassVar[dict[str, object]]
|
||||
|
||||
def validate(instance: object, schema: object) -> None: ...
|
||||
7
types/pilk.pyi
Normal file
7
types/pilk.pyi
Normal file
@@ -0,0 +1,7 @@
|
||||
def encode(
|
||||
input_path: str,
|
||||
output_path: str,
|
||||
*,
|
||||
pcm_rate: int,
|
||||
tencent: bool = ...,
|
||||
) -> float: ...
|
||||
39
types/psutil.pyi
Normal file
39
types/psutil.pyi
Normal file
@@ -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: ...
|
||||
2
types/pyffmpeg.pyi
Normal file
2
types/pyffmpeg.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
class FFmpeg:
|
||||
def convert(self, *, input_file: str, output_file: str) -> None: ...
|
||||
3
types/pysilk.pyi
Normal file
3
types/pysilk.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from io import BytesIO
|
||||
|
||||
def decode(input_io: BytesIO, output_io: BytesIO, sample_rate: int) -> None: ...
|
||||
22
types/readability.pyi
Normal file
22
types/readability.pyi
Normal file
@@ -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: ...
|
||||
11
types/yaml.pyi
Normal file
11
types/yaml.pyi
Normal file
@@ -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: ...
|
||||
Reference in New Issue
Block a user