{"action":"opened","number":257,"pull_request":{"url":"https://api.github.com/repos/alecthomas/voluptuous/pulls/257","id":97037520,"html_url":"https://github.com/alecthomas/voluptuous/pull/257","diff_url":"https://github.com/alecthomas/voluptuous/pull/257.diff","patch_url":"https://github.com/alecthomas/voluptuous/pull/257.patch","issue_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/257","number":257,"state":"open","locked":false,"title":"Added ValidationState object to prevent duplication of reference types","user":{"login":"SimplyKnownAsG","id":1082590,"avatar_url":"https://avatars.githubusercontent.com/u/1082590?v=3","gravatar_id":"","url":"https://api.github.com/users/SimplyKnownAsG","html_url":"https://github.com/SimplyKnownAsG","followers_url":"https://api.github.com/users/SimplyKnownAsG/followers","following_url":"https://api.github.com/users/SimplyKnownAsG/following{/other_user}","gists_url":"https://api.github.com/users/SimplyKnownAsG/gists{/gist_id}","starred_url":"https://api.github.com/users/SimplyKnownAsG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimplyKnownAsG/subscriptions","organizations_url":"https://api.github.com/users/SimplyKnownAsG/orgs","repos_url":"https://api.github.com/users/SimplyKnownAsG/repos","events_url":"https://api.github.com/users/SimplyKnownAsG/events{/privacy}","received_events_url":"https://api.github.com/users/SimplyKnownAsG/received_events","type":"User","site_admin":false},"body":"If you like the idea, I suspect there will be lots of change requests including possible redesign. So, I kinda just want to get it started. I can also merge it with my current pull request (#256) to remove some duplicate stuff (editor formatting and `.vscode/` in `.gitignore`.\r\n\r\nThe concept is effectively to short circuit previously validated values to prevent duplication of reference types (see #253).\r\n\r\n## Design considerations\r\nI tried to maintain backward compatibility pretty much everywhere. I changed the use of `path`, typically used in `validation_func(path, data)` declarations to a variable called `state`, which is an instance of a `ValidatiaonState`. A `ValidationState` is a list-like object that contains two attributes:\r\n1. `_path`  -- this is synonymous with the original `path` variable that was passed around before\r\n2. `_cache` -- this is a nested (2-layer) `dict` with primary keys of \"compiled\" validation funcs, secondary keys of the original data `id` with values being the validated result (typically referred to as `out`). This is to say that the `_cache` is dependent on two things which should limit false short circuits:\r\n2.1. the validation function used\r\n2.2. the `id()` of the original data\r\n\r\nI also tried to modify as little code as possible, but due to the scope it is still pretty significant. To reduce introduced code, I created the `validation_state.check_cache` decorator that is used to decorate all validation functions. This kept things relatively DRY, but could still probably be improved further.\r\n\r\n## things I don't like\r\n* Originally, I tried just passing `path`, and `cache` thinking that would result in the minimal amount of changes, but things got out of hand pretty quickly and method signatures got more and more ugly.\r\n* I created an \"interface\" `StateValidator` that defines the `__call__(self, data, state=None)`. The interface class isn't really required, but I needed to differentiate between a generic `callable` and objects that would pass state through.\r\n* the \"compiled\" functions generated in `schema_builder.py` still have _old_ signatures with `path` replaced by `state`, e.g. `validate_dict(state, data)`. I am not a fan of the inconsistency between `StateValidator.__call__` and the validation functions. Specifically, one is `(state, data)` and the other is `(data, state)`. I'd prefer to make them all `(data, state)`.","created_at":"2016-12-08T00:36:50Z","updated_at":"2016-12-08T00:36:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/alecthomas/voluptuous/pulls/257/commits","review_comments_url":"https://api.github.com/repos/alecthomas/voluptuous/pulls/257/comments","review_comment_url":"https://api.github.com/repos/alecthomas/voluptuous/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/257/comments","statuses_url":"https://api.github.com/repos/alecthomas/voluptuous/statuses/527c66065720fb311469716d94919635354726d2","head":{"label":"SimplyKnownAsG:references","ref":"references","sha":"527c66065720fb311469716d94919635354726d2","user":{"login":"SimplyKnownAsG","id":1082590,"avatar_url":"https://avatars.githubusercontent.com/u/1082590?v=3","gravatar_id":"","url":"https://api.github.com/users/SimplyKnownAsG","html_url":"https://github.com/SimplyKnownAsG","followers_url":"https://api.github.com/users/SimplyKnownAsG/followers","following_url":"https://api.github.com/users/SimplyKnownAsG/following{/other_user}","gists_url":"https://api.github.com/users/SimplyKnownAsG/gists{/gist_id}","starred_url":"https://api.github.com/users/SimplyKnownAsG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimplyKnownAsG/subscriptions","organizations_url":"https://api.github.com/users/SimplyKnownAsG/orgs","repos_url":"https://api.github.com/users/SimplyKnownAsG/repos","events_url":"https://api.github.com/users/SimplyKnownAsG/events{/privacy}","received_events_url":"https://api.github.com/users/SimplyKnownAsG/received_events","type":"User","site_admin":false},"repo":{"id":75785604,"name":"voluptuous","full_name":"SimplyKnownAsG/voluptuous","owner":{"login":"SimplyKnownAsG","id":1082590,"avatar_url":"https://avatars.githubusercontent.com/u/1082590?v=3","gravatar_id":"","url":"https://api.github.com/users/SimplyKnownAsG","html_url":"https://github.com/SimplyKnownAsG","followers_url":"https://api.github.com/users/SimplyKnownAsG/followers","following_url":"https://api.github.com/users/SimplyKnownAsG/following{/other_user}","gists_url":"https://api.github.com/users/SimplyKnownAsG/gists{/gist_id}","starred_url":"https://api.github.com/users/SimplyKnownAsG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimplyKnownAsG/subscriptions","organizations_url":"https://api.github.com/users/SimplyKnownAsG/orgs","repos_url":"https://api.github.com/users/SimplyKnownAsG/repos","events_url":"https://api.github.com/users/SimplyKnownAsG/events{/privacy}","received_events_url":"https://api.github.com/users/SimplyKnownAsG/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SimplyKnownAsG/voluptuous","description":"Voluptuous, despite the name, is a Python data validation library.","fork":true,"url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous","forks_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/forks","keys_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/teams","hooks_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/hooks","issue_events_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/issues/events{/number}","events_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/events","assignees_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/assignees{/user}","branches_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/branches{/branch}","tags_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/tags","blobs_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/git/refs{/sha}","trees_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/statuses/{sha}","languages_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/languages","stargazers_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/stargazers","contributors_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/contributors","subscribers_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/subscribers","subscription_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/subscription","commits_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/commits{/sha}","git_commits_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/git/commits{/sha}","comments_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/comments{/number}","issue_comment_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/issues/comments{/number}","contents_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/contents/{+path}","compare_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/merges","archive_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/downloads","issues_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/issues{/number}","pulls_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/pulls{/number}","milestones_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/milestones{/number}","notifications_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/labels{/name}","releases_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/releases{/id}","deployments_url":"https://api.github.com/repos/SimplyKnownAsG/voluptuous/deployments","created_at":"2016-12-07T01:03:40Z","updated_at":"2016-12-07T01:03:41Z","pushed_at":"2016-12-08T00:35:52Z","git_url":"git://github.com/SimplyKnownAsG/voluptuous.git","ssh_url":"git@github.com:SimplyKnownAsG/voluptuous.git","clone_url":"https://github.com/SimplyKnownAsG/voluptuous.git","svn_url":"https://github.com/SimplyKnownAsG/voluptuous","homepage":"http://pypi.python.org/pypi/voluptuous","size":1863,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"alecthomas:master","ref":"master","sha":"f1b5aa81da42d0b93087528bde862e854d40a96c","user":{"login":"alecthomas","id":41767,"avatar_url":"https://avatars.githubusercontent.com/u/41767?v=3","gravatar_id":"","url":"https://api.github.com/users/alecthomas","html_url":"https://github.com/alecthomas","followers_url":"https://api.github.com/users/alecthomas/followers","following_url":"https://api.github.com/users/alecthomas/following{/other_user}","gists_url":"https://api.github.com/users/alecthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/alecthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alecthomas/subscriptions","organizations_url":"https://api.github.com/users/alecthomas/orgs","repos_url":"https://api.github.com/users/alecthomas/repos","events_url":"https://api.github.com/users/alecthomas/events{/privacy}","received_events_url":"https://api.github.com/users/alecthomas/received_events","type":"User","site_admin":false},"repo":{"id":776374,"name":"voluptuous","full_name":"alecthomas/voluptuous","owner":{"login":"alecthomas","id":41767,"avatar_url":"https://avatars.githubusercontent.com/u/41767?v=3","gravatar_id":"","url":"https://api.github.com/users/alecthomas","html_url":"https://github.com/alecthomas","followers_url":"https://api.github.com/users/alecthomas/followers","following_url":"https://api.github.com/users/alecthomas/following{/other_user}","gists_url":"https://api.github.com/users/alecthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/alecthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alecthomas/subscriptions","organizations_url":"https://api.github.com/users/alecthomas/orgs","repos_url":"https://api.github.com/users/alecthomas/repos","events_url":"https://api.github.com/users/alecthomas/events{/privacy}","received_events_url":"https://api.github.com/users/alecthomas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alecthomas/voluptuous","description":"Voluptuous, despite the name, is a Python data validation library.","fork":false,"url":"https://api.github.com/repos/alecthomas/voluptuous","forks_url":"https://api.github.com/repos/alecthomas/voluptuous/forks","keys_url":"https://api.github.com/repos/alecthomas/voluptuous/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alecthomas/voluptuous/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alecthomas/voluptuous/teams","hooks_url":"https://api.github.com/repos/alecthomas/voluptuous/hooks","issue_events_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/events{/number}","events_url":"https://api.github.com/repos/alecthomas/voluptuous/events","assignees_url":"https://api.github.com/repos/alecthomas/voluptuous/assignees{/user}","branches_url":"https://api.github.com/repos/alecthomas/voluptuous/branches{/branch}","tags_url":"https://api.github.com/repos/alecthomas/voluptuous/tags","blobs_url":"https://api.github.com/repos/alecthomas/voluptuous/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alecthomas/voluptuous/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alecthomas/voluptuous/git/refs{/sha}","trees_url":"https://api.github.com/repos/alecthomas/voluptuous/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alecthomas/voluptuous/statuses/{sha}","languages_url":"https://api.github.com/repos/alecthomas/voluptuous/languages","stargazers_url":"https://api.github.com/repos/alecthomas/voluptuous/stargazers","contributors_url":"https://api.github.com/repos/alecthomas/voluptuous/contributors","subscribers_url":"https://api.github.com/repos/alecthomas/voluptuous/subscribers","subscription_url":"https://api.github.com/repos/alecthomas/voluptuous/subscription","commits_url":"https://api.github.com/repos/alecthomas/voluptuous/commits{/sha}","git_commits_url":"https://api.github.com/repos/alecthomas/voluptuous/git/commits{/sha}","comments_url":"https://api.github.com/repos/alecthomas/voluptuous/comments{/number}","issue_comment_url":"https://api.github.com/repos/alecthomas/voluptuous/issues/comments{/number}","contents_url":"https://api.github.com/repos/alecthomas/voluptuous/contents/{+path}","compare_url":"https://api.github.com/repos/alecthomas/voluptuous/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alecthomas/voluptuous/merges","archive_url":"https://api.github.com/repos/alecthomas/voluptuous/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alecthomas/voluptuous/downloads","issues_url":"https://api.github.com/repos/alecthomas/voluptuous/issues{/number}","pulls_url":"https://api.github.com/repos/alecthomas/voluptuous/pulls{/number}","milestones_url":"https://api.github.com/repos/alecthomas/voluptuous/milestones{/number}","notifications_url":"https://api.github.com/repos/alecthomas/voluptuous/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alecthomas/voluptuous/labels{/name}","releases_url":"https://api.github.com/repos/alecthomas/voluptuous/releases{/id}","deployments_url":"https://api.github.com/repos/alecthomas/voluptuous/deployments","created_at":"2010-07-15T09:55:10Z","updated_at":"2016-12-06T19:34:41Z","pushed_at":"2016-12-08T00:36:50Z","git_url":"git://github.com/alecthomas/voluptuous.git","ssh_url":"git@github.com:alecthomas/voluptuous.git","clone_url":"https://github.com/alecthomas/voluptuous.git","svn_url":"https://github.com/alecthomas/voluptuous","homepage":"http://pypi.python.org/pypi/voluptuous","size":1952,"stargazers_count":709,"watchers_count":709,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":20,"forks":108,"open_issues":20,"watchers":709,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alecthomas/voluptuous/pulls/257"},"html":{"href":"https://github.com/alecthomas/voluptuous/pull/257"},"issue":{"href":"https://api.github.com/repos/alecthomas/voluptuous/issues/257"},"comments":{"href":"https://api.github.com/repos/alecthomas/voluptuous/issues/257/comments"},"review_comments":{"href":"https://api.github.com/repos/alecthomas/voluptuous/pulls/257/comments"},"review_comment":{"href":"https://api.github.com/repos/alecthomas/voluptuous/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alecthomas/voluptuous/pulls/257/commits"},"statuses":{"href":"https://api.github.com/repos/alecthomas/voluptuous/statuses/527c66065720fb311469716d94919635354726d2"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":212,"deletions":87,"changed_files":9}}
{"actor":{"display_login":"SimplyKnownAsG"}}