refactor: add type hints and FileParser.is_supported() helper

- Add return type annotation (list[str]) to Config.validate()
- Add type annotations (msg: str, -> None) to logger convenience functions
- Add FileParser.is_supported() classmethod for checking file format support
This commit is contained in:
lllopic
2026-05-23 14:57:46 +08:00
parent fa0f6519b1
commit daec4b6be4
3 changed files with 21 additions and 7 deletions

View File

@@ -63,6 +63,20 @@ class FileParser:
SUPPORTED_EXTENSIONS = {'.pdf', '.md', '.markdown', '.txt'}
@classmethod
def is_supported(cls, file_path: str) -> bool:
"""
检查文件是否为支持的格式
Args:
file_path: 文件路径
Returns:
如果文件格式受支持则返回 True
"""
suffix = Path(file_path).suffix.lower()
return suffix in cls.SUPPORTED_EXTENSIONS
@classmethod
def extract_text(cls, file_path: str) -> str:
"""