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:
@@ -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:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user