alecthomas / alecthomas/voluptuous

Nested exclusion groups do not function as expected

Open
#302 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.9k
Forks
237
PR merge metrics
No merged PRs in 30d

Description

With the below schema, you would expect "foo" to be exclusive with both "bar" and "baz":
```
>>> s = Schema({Exclusive(Exclusive("foo", 1), 2): str, Exclusive("bar", 1): str, Exclusive("baz", 2): str})
```
However, it appears that the inner 'Exclusive' object is ignored when they are nested. So "foo" does exclude "baz", as expected:
```
>>> s({"foo": "", "baz":"",})
Traceback (most recent call last):
File "", line 1, in
File "/home/wmiller/venv/lib/python2.7/site-packages/voluptuous/schema_builder.py", line 221, in __call__
return self._compiled([], data)
File "/home/wmiller/venv/lib/python2.7/site-packages/voluptuous/schema_builder.py", line 520, in validate_dict
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: two or more values in the same group of exclusion '2' @ data[<2>]
```
But "foo" does **not** exclude "bar":
```
>>> s({"foo": "", "bar":"",})
{'foo': '', 'bar': ''}
```

The tests above were performed on voluptuous 0.10.5.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.