alecthomas / alecthomas/voluptuous

Nested exclusion groups do not function as expected

Offen
#302 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
1.9k
Forks
237
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.