alecthomas / alecthomas/voluptuous
Validating a Mapping that isn't a dict fails
- Lenguaje dominante
- Python
- Estrellas
- 1.9k
- Forks
- 237
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
This is essentially the same issue as #125; it appears maybe this feature is now broken?
I, like #125, am attempting to validate an aiohttp request query arguments, which isn't a `dict`, but is a `Mapping`.
However, `voluptuous` requires a `dict`, as can be seen [here](https://github.com/alecthomas/voluptuous/blob/77ee5da9e33ccd0ec68f2b670d8ef0569c89041f/voluptuous/schema_builder.py#L499-L500); I see this in my stack trace:
```
Traceback (most recent call last):
File "…/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 221, in __call__
return self._compiled([], data)
File "…/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 504, in validate_dict
raise er.DictInvalid('expected a dictionary', path)
voluptuous.error.DictInvalid: expected a dictionary
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "…/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 422, in start
resp = yield from self._request_handler(request)
File "…/lib/python3.6/site-packages/aiohttp/web.py", line 306, in _handle
resp = yield from handler(request)
File "…/__main__.py", line 32, in wrapper
json_data = await func(*args, **kwargs)
File "…/__main__.py", line 88, in foo
validated_qargs = _SCHEMA(request.query)
File "…/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 225, in __call__
raise er.MultipleInvalid([e])
voluptuous.error.MultipleInvalid: expected a dictionary
```
I think it's as simple as changing that `dict` to `Mapping`?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.