traitlets Dict should support a strict keys mode
- Lenguaje dominante
- Python
- Estrellas
- 653
- Forks
- 217
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 2
Descripción
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}
```
Guía de contribución
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100