ipython / ipython/traitlets

traitlets Dict does not observe value changes after initial key / value assigments

Đang mở
#922 2 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ả

I'm using `traitlets` version 5.14.3 and Python 3.12.3...

In both cases below, a `TraitError` is not thrown, even though `None` is assigned to a `Unicode()` field after initialization...

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

class Foo(HasTraits):
data = Dict(per_key_traits={"a_key": Unicode()})

class Bar(HasTraits):
data = Dict(key_trait=Unicode(), value_trait=Unicode())

foo = Foo()
foo.data = {"a_key": "a_value"}
# I think this should throw a TraitError...
foo.data["a_key"] = None

bar = Bar()
bar.data = {"a_key": "a_value"}
# I think this should throw a TraitError...
bar.data["a_key"] = None
```

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.