Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

Add typing_extensions for compatibility and update tomllib encoding in tests

myhloli119fdeec8638
diff --git a/mineru/doclib/rows.py b/mineru/doclib/rows.py
index 84f39afd..eb869092 100644
--- a/mineru/doclib/rows.py
+++ b/mineru/doclib/rows.py
@@ -2,7 +2,8 @@
from __future__ import annotations
-from typing import NotRequired, TypedDict
+# Python 3.10 的 typing 尚未提供 NotRequired,统一使用兼容实现。
+from typing_extensions import NotRequired, TypedDict
from ..types import Tier
from .types import ParseStatus, RuleType, ScanKind, ScanSource, FileStatus, ScanStatus, WatchStatus
diff --git a/pyproject.toml b/pyproject.toml
index 704efe1b..c4c80b79 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -67,6 +67,7 @@ dependencies = [
"python-multipart",
"uvicorn",
"pydantic>=2.12.5,<3",
+ "typing_extensions>=4.0.0",
"typer>=0.9.0",
"rich>=13.0.0",
"jieba>=0.42.1",
diff --git a/tests/unittest/test_model_backend_selection.py b/tests/unittest/test_model_backend_selection.py
index b5796b32..55fb797c 100644
--- a/tests/unittest/test_model_backend_selection.py
+++ b/tests/unittest/test_model_backend_selection.py
@@ -201,7 +201,7 @@ def test_standard_dependency_errors_survive_startup_wrappers(
def _resolved_direct_dependencies(platform: str, machine: str, extra: str) -> set[str]:
"""按目标平台展开本项目的递归 extra,不使用宿主环境的标记值。"""
- project = tomllib.loads((Path(__file__).resolve().parents[2] / "pyproject.toml").read_text())["project"]
+ project = tomllib.loads((Path(__file__).resolve().parents[2] / "pyproject.toml").read_text(encoding="utf-8"))["project"]
environment = {**default_environment(), "sys_platform": platform, "platform_machine": machine}
pending, visited, names = [extra], set(), set()
while pending:
@@ -237,7 +237,7 @@ def test_package_markers(platform: str, machine: str, extra: str) -> None:
assert ("vllm" in names) == (platform == "linux" and extra in {"full", "all"})
assert ("lmdeploy" in names) == (platform == "win32" and extra in {"full", "all"})
assert "mlx-vlm" not in names
- project = tomllib.loads((Path(__file__).resolve().parents[2] / "pyproject.toml").read_text())["project"]
+ project = tomllib.loads((Path(__file__).resolve().parents[2] / "pyproject.toml").read_text(encoding="utf-8"))["project"]
assert "gradio" not in project["optional-dependencies"]