ipython / ipython/traitlets

Issue with default_value for List trait

オープン
#366 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
653
フォーク
217
平均マージ
2日 21時間
マージ済み PR(30日)
2

説明

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
[]

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。