ipython / ipython/traitlets

Instance trait type default value confusion

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

説明

We raise here:

``` python
class A(HasTraits):
inst = Instance(Foo)

A().inst
```

But not here:

``` python
class A(HasTraits):
inst = Instance(Foo, allow_none=True)

A().inst
```

This seems magical, and is not at all implied by `allow_none=True`.

We should probably try to enforce this convention:

``` python
class A(HasTraits):
inst = Instance(Foo, default_value=None, allow_none=True)

A().inst
```

Or at the very least:

set `allow_none=True` if `default_value=None`

``` python
class A(HasTraits):
inst = Instance(Foo, default_value=None)

A().inst
```

This isn't backwards compatible, but IMO it resolves a bug.

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

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

評価

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

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

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