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

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

説明

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

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

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

評価

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

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

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