From 22f8d2110d028f73b36ba3b24af0e083b44241b5 Mon Sep 17 00:00:00 2001 From: gooker_young Date: Sat, 27 Jun 2026 19:35:11 +0800 Subject: [PATCH] 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 --- pyproject.toml | 5 ++++- src/pyflowx/cli/envdev.py | 26 +++++++++++++++++--------- src/pyflowx/executors.py | 1 + src/pyflowx/task.py | 4 ++-- uv.lock | 17 +++++++++++++++-- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index db4a2af..1906c01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,10 @@ packages = ["src/pyflowx"] pyflowx = { workspace = true } [dependency-groups] -dev = ["pyflowx[dev,office,llm]"] +dev = [ + "pyflowx[dev,office,llm]", + "pysnooper>=1.2.3", +] [tool.coverage.run] branch = true diff --git a/src/pyflowx/cli/envdev.py b/src/pyflowx/cli/envdev.py index 09f2e6e..04241b6 100644 --- a/src/pyflowx/cli/envdev.py +++ b/src/pyflowx/cli/envdev.py @@ -17,23 +17,26 @@ INSTALL_MIRROR_SCRIPT: str = "sudo bash /tmp/linuxmirrors.sh" # ============================================================================ # Python 配置 # ============================================================================ -PyMirrorType = Literal["tsinghua", "aliyun"] +PyMirrorType = Literal["tsinghua", "aliyun", "huaweicloud", "ustc", "zju"] PIP_INDEX_URLS: dict[PyMirrorType, str] = { "tsinghua": "https://pypi.tuna.tsinghua.edu.cn/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] = { "tsinghua": "pypi.tuna.tsinghua.edu.cn", "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" -UV_INDEX_URLS: dict[PyMirrorType, str] = { - "tsinghua": "https://pypi.tuna.tsinghua.edu.cn/simple", - "aliyun": "https://mirrors.aliyun.com/pypi/simple/", -} +UV_INDEX_URLS = PIP_INDEX_URLS UV_PYTHON_INSTALL_MIRROR: str = "https://registry.npmmirror.com/-/binary/python-build-standalone" # ============================================================================ @@ -155,7 +158,7 @@ def main() -> None: # 使用 conditions 自动控制任务执行 graph = px.Graph.from_specs([ - # 系统镜像配置(仅 Linux 且未配置) + # 系统镜像配置(仅 Linux 且未配置国内镜像) px.TaskSpec( "download_mirror", cmd=DOWNLOAD_MIRROR_SCRIPT, @@ -163,9 +166,14 @@ def main() -> None: BuiltinConditions.IS_LINUX(), BuiltinConditions.NOT( BuiltinConditions.OR( - BuiltinConditions.FILE_CONTENT_EXISTS("/etc/apt/sources.list", "tsinghua"), - BuiltinConditions.FILE_CONTENT_EXISTS("/etc/apt/sources.list", "aliyun"), - BuiltinConditions.FILE_CONTENT_EXISTS("/etc/apt/sources.list", "ustc"), + *[ + BuiltinConditions.FILE_CONTENT_EXISTS(f, m) + for f in [ + "/etc/apt/sources.list", + "/etc/apt/sources.list.d/ubuntu.sources", + ] + for m in get_args(PyMirrorType) + ], ) ), ), diff --git a/src/pyflowx/executors.py b/src/pyflowx/executors.py index 4a6207c..bc93471 100644 --- a/src/pyflowx/executors.py +++ b/src/pyflowx/executors.py @@ -130,6 +130,7 @@ def _evaluate_conditions(spec: TaskSpec[Any], context: Mapping[str, Any]) -> str name = getattr(condition, "__name__", None) or "匿名条件(执行错误)" failed_conditions.append(name) continue + if not ok: failed_conditions.append(getattr(condition, "__name__", None) or "匿名条件") diff --git a/src/pyflowx/task.py b/src/pyflowx/task.py index 1934915..d3bcea5 100644 --- a/src/pyflowx/task.py +++ b/src/pyflowx/task.py @@ -31,8 +31,8 @@ from typing import ( Callable, ContextManager, Coroutine, + Generator, Generic, - Iterator, List, Mapping, Union, @@ -367,7 +367,7 @@ class TaskSpec(Generic[T]): def _env_and_cwd( env: Mapping[str, str] | None, cwd: Path | None, -) -> Iterator[None]: +) -> Generator[None, None, None]: """临时设置环境变量与工作目录。""" saved_env: dict[str, str] = {} saved_cwd: str | None = None diff --git a/uv.lock b/uv.lock index eda6d24..0fbb470 100644 --- a/uv.lock +++ b/uv.lock @@ -5603,7 +5603,7 @@ pycountry = [ [[package]] name = "pyflowx" -version = "0.2.8" +version = "0.2.9" source = { editable = "." } dependencies = [ { name = "graphlib-backport", marker = "python_full_version < '3.9'" }, @@ -5658,6 +5658,7 @@ office = [ [package.dev-dependencies] dev = [ { name = "pyflowx", extra = ["dev", "llm", "office"] }, + { name = "pysnooper" }, ] [package.metadata] @@ -5686,7 +5687,10 @@ requires-dist = [ provides-extras = ["dev", "llm", "office"] [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]] 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" }, ] +[[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]] name = "pytesseract" version = "0.3.13"