ipython / ipython/traitlets

If the default value for Unicode is traitlets.Undefined, then why is it type string when tested? How can you enforce CLI definition of an attribute if it self-massages to ""?

Aperta
#732 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
653
Fork
217
Merge medio
2g 21h
PR unite (30g)
2

Descrizione

The code below shows that even though `x` is never given a value, it is an empty string.

Why do [the docs](https://traitlets.readthedocs.io/en/stable/trait_types.html#traitlets.Unicode) for `Unicode` state `default_value=traitlets.Undefined` yet the type is string when tested?

```python
from traitlets.config import Application
from traitlets import List, Dict, Integer, Unicode

class App(Application):

aliases = {"x": "App.x", "y": "App.y"}
x = Unicode().tag(config=True)
y = Unicode().tag(config=True)

def start(self):
print(f"typex = {type(self.x)} val={self.x}")
print(f"y={self.y}")

if __name__ == "__main__":
App.launch_instance()
```

## Output

```python
typex = val=
y=
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.