skills/cann-log-analysis/readme.md 的“前置条件”声明: Python 3.7+(用于运行清洗脚本)。
skills/cann-log-analysis/readme.md
但 eval-skill/scripts/ 下的脚本使用了旧版 Python 不支持在运行时求值的类型注解,导致导入或启动时抛出 TypeError,连 --help 都无法正常执行。
eval-skill/scripts/
--help
datetime | None
list[str]
tuple[str, str]
str | None
dict | None
在仓库根目录,使用对应版本的 Python 执行:
python3.8 skills/cann-log-analysis/eval-skill/scripts/clean.py --help python3.8 skills/cann-log-analysis/eval-skill/scripts/assess_confidence.py --help python3.9 skills/cann-log-analysis/eval-skill/scripts/promote_case.py --help
典型错误:
TypeError: 'type' object is not subscriptable TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
脚本能够在文档声明支持的 Python 版本下正常导入和运行。
建议将相关类型注解改为兼容旧版本的 typing.List、typing.Tuple、typing.Dict、typing.Optional, 并补充旧版本 Python 的启动检查。
typing.List
typing.Tuple
typing.Dict
typing.Optional
问题描述
skills/cann-log-analysis/readme.md的“前置条件”声明:Python 3.7+(用于运行清洗脚本)。
但
eval-skill/scripts/下的脚本使用了旧版 Python 不支持在运行时求值的类型注解,导致导入或启动时抛出 TypeError,连--help都无法正常执行。受影响的脚本
datetime | None和list[str],在 Python 3.7–3.9 下导入失败。tuple[str, str],在 Python 3.7/3.8 下导入失败;Python 3.9 可以导入。str | None、dict | None,在 Python 3.7–3.9 下导入失败。复现方法
在仓库根目录,使用对应版本的 Python 执行:
python3.8 skills/cann-log-analysis/eval-skill/scripts/clean.py --help python3.8 skills/cann-log-analysis/eval-skill/scripts/assess_confidence.py --help python3.9 skills/cann-log-analysis/eval-skill/scripts/promote_case.py --help典型错误:
期望行为
脚本能够在文档声明支持的 Python 版本下正常导入和运行。
建议将相关类型注解改为兼容旧版本的
typing.List、typing.Tuple、typing.Dict、typing.Optional,并补充旧版本 Python 的启动检查。