ipython / ipython/traitlets

Better insight on dictionary of traits instantiation

Open
#549 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
653
Forks
217
Avg merge
2d 21h
Merged PRs (30d)
2

Description

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')
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.