ipython / ipython/traitlets

traitlets Dict should support a strict keys mode

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

説明

Please add support for a way to restrict keys on a `Dict`...

Example of what should raise a `TraitError`

```python
from traitlets import HasTraits, Dict, Unicode

class Foo(HasTraits):
# the strict_keys keyword is a suggested feature...
data = Dict(per_key_traits={"this_key": Unicode()}, strict_keys=True)

foo = Foo()

# This is fine...
foo.data = {"this_key": "value"}

# This should raise a TraitError
foo.data = {"invalid_key": None}
```

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

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

評価

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

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

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