alecthomas / voluptuous

CONTRIBUTIONS ONLY: Voluptuous, despite the name, is a Python data validation library.
https://pypi.org/project/voluptuous
BSD 3-Clause "New" or "Revised" License
1.82k stars 218 forks source link

Empty lists behaving incorrectly #397

Closed ChristopherChudzicki closed 3 years ago

ChristopherChudzicki commented 5 years ago

We're in the process of upgrading from version 0.10.5 to version 0.11.5, and empty list validation is now giving strange errors:

from voluptuous import Schema, Required, MultipleInvalid

schema = Schema({
    Required('variables', default=[]): []
})

try:
    schema({'variables': ['x']})
except MultipleInvalid as error:
    print(error)
# in 0.10.5: not a valid value for dictionary value @ data['variables']
# in 0.11.5: not a valid value for dictionary value @ data['x']

The error message doesn't make sense to me...there is no dictionary with key 'x'.

alecthomas commented 5 years ago

That seems like a bug.