ipython / ipython/traitlets

How to create required CLI config options?

未关闭
#828 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
653
派生
217
平均合并
2 天 21 小时
30 天内合并 PR
2

描述

In https://github.com/ipython/traitlets/issues/490 this issue was raised and then closed by @rmorshea.

However,
* [searching the docs for mandatory](https://traitlets.readthedocs.io/en/stable/search.html?q=mandatory#) yields nothing
* [searching the docs for required](https://traitlets.readthedocs.io/en/stable/search.html?q=required#) doesnt yield any relevant docs.

So:

1. How does one flag an attribute as mandatory?
2. Is this documented and did I miss it?

Here is a code sample for you to elide with what is necessary to make the `req` attribute mandatory:

```python

class App(Application):
optional_arg = Int(config=True)
req = Unicode(config=True)

```

I'm expecting an exception to be thrown when I invoke this app without providing req:

```
python my_app.py --App.optional_arg=5
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。