chore: add pysnooper dev dependency and update configs

1. add pysnooper>=1.2.3 to dev dependencies in pyproject.toml and uv.lock
2. update type hints in task.py from Iterator to Generator
3. add more PyPI mirrors and update envdev.py comments and checks
4. fix trailing whitespace in executors.py
This commit is contained in:
2026-06-27 19:35:11 +08:00
parent 2a1f2f7175
commit 22f8d2110d
5 changed files with 39 additions and 14 deletions
+4 -1
View File
@@ -93,7 +93,10 @@ packages = ["src/pyflowx"]
pyflowx = { workspace = true } pyflowx = { workspace = true }
[dependency-groups] [dependency-groups]
dev = ["pyflowx[dev,office,llm]"] dev = [
"pyflowx[dev,office,llm]",
"pysnooper>=1.2.3",
]
[tool.coverage.run] [tool.coverage.run]
branch = true branch = true
+17 -9
View File
@@ -17,23 +17,26 @@ INSTALL_MIRROR_SCRIPT: str = "sudo bash /tmp/linuxmirrors.sh"
# ============================================================================ # ============================================================================
# Python 配置 # Python 配置
# ============================================================================ # ============================================================================
PyMirrorType = Literal["tsinghua", "aliyun"] PyMirrorType = Literal["tsinghua", "aliyun", "huaweicloud", "ustc", "zju"]
PIP_INDEX_URLS: dict[PyMirrorType, str] = { PIP_INDEX_URLS: dict[PyMirrorType, str] = {
"tsinghua": "https://pypi.tuna.tsinghua.edu.cn/simple", "tsinghua": "https://pypi.tuna.tsinghua.edu.cn/simple",
"aliyun": "https://mirrors.aliyun.com/pypi/simple/", "aliyun": "https://mirrors.aliyun.com/pypi/simple/",
"huaweicloud": "https://mirrors.huaweicloud.com/repository/pypi/simple/",
"ustc": "https://pypi.mirrors.ustc.edu.cn/simple/",
"zju": "https://mirrors.zju.edu.cn/pypi/simple/",
} }
PIP_TRUSTED_HOSTS: dict[PyMirrorType, str] = { PIP_TRUSTED_HOSTS: dict[PyMirrorType, str] = {
"tsinghua": "pypi.tuna.tsinghua.edu.cn", "tsinghua": "pypi.tuna.tsinghua.edu.cn",
"aliyun": "mirrors.aliyun.com", "aliyun": "mirrors.aliyun.com",
"huaweicloud": "mirrors.huaweicloud.com",
"ustc": "pypi.mirrors.ustc.edu.cn",
"zju": "mirrors.zju.edu.cn",
} }
PIP_CONFIG_PATH = Path.home() / ".pip" / "pip.conf" if BuiltinConditions.IS_LINUX() else Path.home() / "pip" / "pip.ini" PIP_CONFIG_PATH = Path.home() / ".pip" / "pip.conf" if BuiltinConditions.IS_LINUX() else Path.home() / "pip" / "pip.ini"
UV_INDEX_URLS: dict[PyMirrorType, str] = { UV_INDEX_URLS = PIP_INDEX_URLS
"tsinghua": "https://pypi.tuna.tsinghua.edu.cn/simple",
"aliyun": "https://mirrors.aliyun.com/pypi/simple/",
}
UV_PYTHON_INSTALL_MIRROR: str = "https://registry.npmmirror.com/-/binary/python-build-standalone" UV_PYTHON_INSTALL_MIRROR: str = "https://registry.npmmirror.com/-/binary/python-build-standalone"
# ============================================================================ # ============================================================================
@@ -155,7 +158,7 @@ def main() -> None:
# 使用 conditions 自动控制任务执行 # 使用 conditions 自动控制任务执行
graph = px.Graph.from_specs([ graph = px.Graph.from_specs([
# 系统镜像配置(仅 Linux 且未配置) # 系统镜像配置(仅 Linux 且未配置国内镜像
px.TaskSpec( px.TaskSpec(
"download_mirror", "download_mirror",
cmd=DOWNLOAD_MIRROR_SCRIPT, cmd=DOWNLOAD_MIRROR_SCRIPT,
@@ -163,9 +166,14 @@ def main() -> None:
BuiltinConditions.IS_LINUX(), BuiltinConditions.IS_LINUX(),
BuiltinConditions.NOT( BuiltinConditions.NOT(
BuiltinConditions.OR( BuiltinConditions.OR(
BuiltinConditions.FILE_CONTENT_EXISTS("/etc/apt/sources.list", "tsinghua"), *[
BuiltinConditions.FILE_CONTENT_EXISTS("/etc/apt/sources.list", "aliyun"), BuiltinConditions.FILE_CONTENT_EXISTS(f, m)
BuiltinConditions.FILE_CONTENT_EXISTS("/etc/apt/sources.list", "ustc"), for f in [
"/etc/apt/sources.list",
"/etc/apt/sources.list.d/ubuntu.sources",
]
for m in get_args(PyMirrorType)
],
) )
), ),
), ),
+1
View File
@@ -130,6 +130,7 @@ def _evaluate_conditions(spec: TaskSpec[Any], context: Mapping[str, Any]) -> str
name = getattr(condition, "__name__", None) or "匿名条件(执行错误)" name = getattr(condition, "__name__", None) or "匿名条件(执行错误)"
failed_conditions.append(name) failed_conditions.append(name)
continue continue
if not ok: if not ok:
failed_conditions.append(getattr(condition, "__name__", None) or "匿名条件") failed_conditions.append(getattr(condition, "__name__", None) or "匿名条件")
+2 -2
View File
@@ -31,8 +31,8 @@ from typing import (
Callable, Callable,
ContextManager, ContextManager,
Coroutine, Coroutine,
Generator,
Generic, Generic,
Iterator,
List, List,
Mapping, Mapping,
Union, Union,
@@ -367,7 +367,7 @@ class TaskSpec(Generic[T]):
def _env_and_cwd( def _env_and_cwd(
env: Mapping[str, str] | None, env: Mapping[str, str] | None,
cwd: Path | None, cwd: Path | None,
) -> Iterator[None]: ) -> Generator[None, None, None]:
"""临时设置环境变量与工作目录。""" """临时设置环境变量与工作目录。"""
saved_env: dict[str, str] = {} saved_env: dict[str, str] = {}
saved_cwd: str | None = None saved_cwd: str | None = None
Generated
+15 -2
View File
@@ -5603,7 +5603,7 @@ pycountry = [
[[package]] [[package]]
name = "pyflowx" name = "pyflowx"
version = "0.2.8" version = "0.2.9"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "graphlib-backport", marker = "python_full_version < '3.9'" }, { name = "graphlib-backport", marker = "python_full_version < '3.9'" },
@@ -5658,6 +5658,7 @@ office = [
[package.dev-dependencies] [package.dev-dependencies]
dev = [ dev = [
{ name = "pyflowx", extra = ["dev", "llm", "office"] }, { name = "pyflowx", extra = ["dev", "llm", "office"] },
{ name = "pysnooper" },
] ]
[package.metadata] [package.metadata]
@@ -5686,7 +5687,10 @@ requires-dist = [
provides-extras = ["dev", "llm", "office"] provides-extras = ["dev", "llm", "office"]
[package.metadata.requires-dev] [package.metadata.requires-dev]
dev = [{ name = "pyflowx", extras = ["dev", "office", "llm"], editable = "." }] dev = [
{ name = "pyflowx", extras = ["dev", "office", "llm"], editable = "." },
{ name = "pysnooper", specifier = ">=1.2.3" },
]
[[package]] [[package]]
name = "pygments" name = "pygments"
@@ -6003,6 +6007,15 @@ wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/42/3d/4c6bcb3d456835f51445d3662a428f56c3ea5643ec798c577030ae34298c/pyrefly-1.1.1-py3-none-win_arm64.whl", hash = "sha256:83baf0db71e172665db1fca0ced50b8f7773f5192ca57e8ac6773a772b6d2fc5" }, { url = "https://mirrors.aliyun.com/pypi/packages/42/3d/4c6bcb3d456835f51445d3662a428f56c3ea5643ec798c577030ae34298c/pyrefly-1.1.1-py3-none-win_arm64.whl", hash = "sha256:83baf0db71e172665db1fca0ced50b8f7773f5192ca57e8ac6773a772b6d2fc5" },
] ]
[[package]]
name = "pysnooper"
version = "1.2.3"
source = { registry = "https://mirrors.aliyun.com/pypi/simple/" }
sdist = { url = "https://mirrors.aliyun.com/pypi/packages/d2/4a/be3c144f58de6b78911c417cc4a3b3fe5eb6d13cae4c12daf3ca17a8d473/pysnooper-1.2.3.tar.gz", hash = "sha256:1fa1425444a7af45108aaed860b5ca8b62b25bba25b0b037c059ba353d8f1e74" }
wheels = [
{ url = "https://mirrors.aliyun.com/pypi/packages/69/87/df62c8a998216e6749b67d548dae0967906036c61457510ef49667927c49/PySnooper-1.2.3-py2.py3-none-any.whl", hash = "sha256:546372f0e72da89f8d1b89e758b7c05a478d65288569a1ca2cc1620e7b1b1944" },
]
[[package]] [[package]]
name = "pytesseract" name = "pytesseract"
version = "0.3.13" version = "0.3.13"