ipython / ipython/traitlets

Better insight on dictionary of traits instantiation

未关闭
#549 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
653
派生
217
平均合并
2 天 21 小时
30 天内合并 PR
2

描述

In the code, when an instance of traits dictionary is created, if an error occurs in a element construction, the original error message is not used. This makes it more complicated to figure out what went wrong.

https://github.com/ipython/traitlets/blob/32ced29b0ab06914ff92e9bdcd8806536633d701/traitlets/traitlets.py#L2835-L2845

It would be nice to add the catch error message to the newly created element error.

```diff
if key_trait:
try:
key = key_trait._validate(obj, key)
except TraitError as error:
- self.element_error(obj, key, key_trait, 'Keys')
+ self.element_error(obj, key, key_trait, str(error), 'Keys')
active_value_trait = per_key_override.get(key, value_trait)
if active_value_trait:
try:
v = active_value_trait._validate(obj, v)
except TraitError as error:
- self.element_error(obj, v, active_value_trait, 'Values')
+ self.element_error(obj, v, active_value_trait, str(error), 'Values')
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。