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.81k stars 219 forks source link

Fix bug with Any validator and REMOVE_EXTRA #524

Open zxdavb opened 3 weeks ago

zxdavb commented 3 weeks ago

I refer to the bug fixed by PR #522.

I am getting a similar issue, and I note that this test would fail with 0.15.2 (but not 0.13.1):

def test_key4():
    schema = Schema(
        {
            Any("name", "area"): str,
            "domain": str,
        },
        extra=REMOVE_EXTRA,  # instead of ALLOW_EXTRA
    )
    schema(
        {
            "name": "one",
            "domain": "two",
            "additional_key": "extra",
        }
    )

This PR offers a fix for the above, and extends the tests to all 4 possible variants of extra=.

Regarding the impact of this PR upon the goals of PR #479 - I note that test_key1 and test_key2 continue to pass.