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 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
653
派生
217
平均合并
2 天 21 小时
30 天内合并 PR
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 摘要。