ipython / ipython/traitlets

How to create required CLI config options?

Đang mở
#828 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
653
Fork
217
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
2

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.