Common base class for CEL exceptions, without breaking the existing builtin mappings
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
首先检查 python/cel/exceptions.py、map_execution_error_to_python、cel.pyi 和错误处理操作指南。跟踪现有的执行错误和解析错误映射,然后验证新的层次结构是否保留内置异常处理、支持捕获 cel.CelError,并在存根和操作指南表格中记录相关内容。
由索引模型根据 Issue 内容生成。
描述
Follow-up promised when closing #23. Execution errors are mapped to the idiomatic builtin (RuntimeError, TypeError, KeyError, IndexError, ZeroDivisionError, OverflowError) and parse errors to ValueError, which is right for each case but means "did the rule run and fail" needs a five-clause except:
except (RuntimeError, TypeError, KeyError, IndexError, ArithmeticError):
Proposal
Add a cel.CelError hierarchy whose members also inherit from the builtin they replace, so nothing existing breaks:
class CelError(Exception): ...
class CelParseError(CelError, ValueError): ...
class CelRuntimeError(CelError, RuntimeError): ...
class CelTypeError(CelError, TypeError): ...
class CelKeyError(CelError, KeyError): ...
class CelIndexError(CelError, IndexError): ...
class CelZeroDivisionError(CelError, ZeroDivisionError): ...
class CelOverflowError(CelError, OverflowError): ...
except TypeError keeps working; except cel.CelError catches everything CEL raised; except cel.CelParseError separates a bad rule from a failed check.
Implementation notes
PyO3's create_exception! only takes a single base, so define the classes in a small python/cel/exceptions.py and have map_execution_error_to_python look them up from the module once (a GILOnceCell<Py<PyType>> per class) and raise with PyErr::from_type. Add them to cel.pyi and to the error-handling how-to, whose current table becomes the mapping between the two hierarchies.
- 主要语言
- Python
- 星标
- 43
- 派生
- 4
- 平均合并
- 9 小时 57 分钟
- 30 天内合并 PR
- 14
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
hardbyte/python-common-expression-language 的其他 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
-
enhancement
难度 4/5 3-5 天 新手友好度 45/100
-
难度 5/5 一周以上 新手友好度 35/100
-
enhancement
难度 5/5 一周以上 新手友好度 45/100
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
查看 hardbyte/python-common-expression-language 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·