traitlets Dict does not observe value changes after initial key / value assigments
- 主要语言
- Python
- 星标
- 653
- 派生
- 217
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 2
描述
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
```
贡献指南
调研方向
Start by running the two Python reproductions in the issue against traitlets 5.14.3, then trace Dict validation for mutations after initial assignment. Done means both invalid value assignments raise TraitError and regression coverage verifies the per-key and key/value trait cases.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100