ipython / ipython/traitlets

Duplicate invocation of validate() on Configurable._load_config()

Offen
#467 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
653
Forks
217
Ø Merge
2 T. 21 Std.
Gemergte PRs (30 T.)
2

Beschreibung

This simple code below on latest sources invokes `TraitType.validate()` twice. Beside a performance issue, this behavior forbids complex "converting" traits because the input value might be converted twice.
```python
import traitlets as trt, traitlets.config as trc

class C(trc.Configurable):
i=trt.CInt(config=True)

C(config=trc.Config({'C': {'i': '1'}})) ## CInt.validate() invoked twice with '1' & 1.
```

The reason is that `hold_trait_notifications()` context-manager in `_load_config()` re-sets the trait-value on exit (L1172): https://github.com/ipython/traitlets/blob/15319254d70d61cf667d28243933f541a9bbe75b/traitlets/traitlets.py#L1167-L1172

I would expect #390 to have fixed this.
- Is duplication on purpose?
- Is there something wrong with my understanding?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.