ipython / ipython/traitlets

traitlets Dict should support a strict keys mode

Đang mở
#921 0 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ả

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

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

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

Hướng nghiên cứu

Start by locating the Dict implementation and its handling of per_key_traits. Add coverage for the strict_keys example, including acceptance of declared keys and a TraitError for invalid keys; done means the requested behavior is tested and works.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
tooling
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

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.