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 ""?

Abierto
#732 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
653
Forks
217
Merge medio
2 d 21 h
PR fusionados (30 d)
2

Descripción

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=
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.