traitlets Dict should support a strict keys mode
Aperta
- Lingua principale
- Python
- Stelle
- 653
- Fork
- 217
- Merge medio
- 2g 21h
- PR unite (30g)
- 2
Descrizione
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}
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.