ipython / ipython/traitlets

Better insight on dictionary of traits instantiation

Ouverte
#549 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
653
Forks
217
Merge moyen
2 j 21 h
PR mergées (30 j)
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')
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.