为所有函数和类添加中文注释文档字符串

This commit is contained in:
2026-06-10 10:34:11 +08:00
parent c612a7ad71
commit c3f93e4441
29 changed files with 103 additions and 17 deletions
+3
View File
@@ -29,6 +29,7 @@ _SECTION_CLASS = {
def _dict_to_dataclass(cls: type, data: dict[str, Any] | None) -> dict[str, Any]:
"""将字典过滤为仅包含指定dataclass字段的键值对"""
if data is None:
return {}
field_names = {f.name for f in dataclasses.fields(cls)}
@@ -36,6 +37,7 @@ def _dict_to_dataclass(cls: type, data: dict[str, Any] | None) -> dict[str, Any]
def _read_yaml(path: Path) -> dict[str, Any]:
"""读取YAML配置文件并返回字典"""
if not path.exists():
return {}
with open(path, encoding="utf-8") as f:
@@ -43,6 +45,7 @@ def _read_yaml(path: Path) -> dict[str, Any]:
def load_config(config_path: str | Path | None = None) -> AppConfig:
"""加载并解析应用配置,返回AppConfig实例"""
if config_path is None:
config_path = _PROJECT_ROOT / "config.yaml"