ipython / ipython/traitlets

Issue with default_value for List trait

Abierto
#366 7 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

I can't seem to set `default_value` of `List` trait to be `None`. When I try to set it the using the `default_value` argument in the constructor, the value is set to `[]`. After initialization I can set it to `None`. I am using `traitlets 4.3.1`. It works when the trait is an `Instance` of `List`.

```python
from traitlets import List, Instance
from ipywidgets import DOMWidget

class Test(DOMWidget):
arr = Instance(List, default_value=None, allow_none=True).tag(sync=True)
arr_2 = List(default_value=None, allow_none=True).tag(sync=True)

test_obj = Test()
print(test_obj.arr is None)
print(test_obj.arr_2 is None)
print(test_obj.arr_2)
```

Output:
True
False
[]

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.