{"action":"closed","issue":{"url":"https://api.github.com/repos/alecthomas/voluptuous/issues/219","repository_url":"https://api.github.com/repos/alecthomas/voluptuous","labels_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/219/comments","events_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/219/events","html_url":"https://github.com/alecthomas/voluptuous/issues/219","id":179525724,"number":219,"title":"Extending schema to change properties of existing keys","user":{"login":"mprager","id":3528569,"avatar_url":"https://avatars.githubusercontent.com/u/3528569?v=3","gravatar_id":"","url":"https://api.github.com/users/mprager","html_url":"https://github.com/mprager","followers_url":"https://api.github.com/users/mprager/followers","following_url":"https://api.github.com/users/mprager/following{/other_user}","gists_url":"https://api.github.com/users/mprager/gists{/gist_id}","starred_url":"https://api.github.com/users/mprager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mprager/subscriptions","organizations_url":"https://api.github.com/users/mprager/orgs","repos_url":"https://api.github.com/users/mprager/repos","events_url":"https://api.github.com/users/mprager/events{/privacy}","received_events_url":"https://api.github.com/users/mprager/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-27T15:23:43Z","updated_at":"2016-10-21T16:02:21Z","closed_at":"2016-10-21T16:02:21Z","body":"Currently modifying key types in an existing schema duplicates the keys and causes all objects to fail validation. Consider this example:\r\n\r\n```\r\n>>> s1 = Schema({Optional('a'): int})\r\n>>> s2 = s1.extend({Required('a'): int})\r\n>>> s1.schema\r\n{'a': <type 'int'>}\r\n>>> s2.schema\r\n{'a': <type 'int'>, 'a': <type 'int'>}\r\n```\r\n\r\nThe s2 object now cannot pass validation for any object, since all 'a' keys will be considered for the optional key and the required key appears absent.\r\n\r\n```\r\n>>> s1({})\r\n{}\r\n>>> s1({'a': 3})\r\n{'a': 3}\r\n>>> s2({})\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/home/mprager/.virtualenv/validator/lib/python2.7/site-packages/voluptuous/schema_builder.py\", line 192, in __call__\r\n    return self._compiled([], data)\r\n  File \"/home/mprager/.virtualenv/validator/lib/python2.7/site-packages/voluptuous/schema_builder.py\", line 486, in validate_dict\r\n    return base_validate(path, iteritems(data), out)\r\n  File \"/home/mprager/.virtualenv/validator/lib/python2.7/site-packages/voluptuous/schema_builder.py\", line 324, in validate_mapping\r\n    raise er.MultipleInvalid(errors)\r\nvoluptuous.error.MultipleInvalid: required key not provided @ data['a']\r\n>>> s2({'a':4})\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/home/mprager/.virtualenv/validator/lib/python2.7/site-packages/voluptuous/schema_builder.py\", line 192, in __call__\r\n    return self._compiled([], data)\r\n  File \"/home/mprager/.virtualenv/validator/lib/python2.7/site-packages/voluptuous/schema_builder.py\", line 486, in validate_dict\r\n    return base_validate(path, iteritems(data), out)\r\n  File \"/home/mprager/.virtualenv/validator/lib/python2.7/site-packages/voluptuous/schema_builder.py\", line 324, in validate_mapping\r\n    raise er.MultipleInvalid(errors)\r\nvoluptuous.error.MultipleInvalid: required key not provided @ data['a']\r\n```\r\n"}}
{"actor":{"display_login":"tusharmakkar08"}}