GitHub PullRequestReviewCommentEvent at 2014-10-07 07:49:55
Repository: traits
Actor: mdickinson
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/enthought/traits/pulls/comments/18505000","id":18505000,"diff_hunk":"@@ -2129,6 +2129,45 @@ def init_fast_validator ( self, *args ):\n \n         self.fast_validate = args\n \n+class ValidatedTuple( BaseTuple ):\n+    \"\"\" A Tuple trait that support custom validation.\n+\n+    Initializing the trait with a ``validation`` keyword set to a function\n+    will define a custom validation to take place during the ``validate``\n+    state of the Trait. The validation function should accept the tuple\n+    value and return True/False for validation.\n+\n+    \"\"\"\n+\n+    def __init__( self, *types, **metadata ):\n+        \"\"\" Returns a TupleFloatRange trait\n+","path":"traits/trait_types.py","position":25,"original_position":25,"commit_id":"2dc9ad65735b87a7cf5ecb2d8b4fc41fde4b2dc4","original_commit_id":"2dc9ad65735b87a7cf5ecb2d8b4fc41fde4b2dc4","user":{"login":"mdickinson","id":662003,"avatar_url":"https://avatars.githubusercontent.com/u/662003?v=2","gravatar_id":"","url":"https://api.github.com/users/mdickinson","html_url":"https://github.com/mdickinson","followers_url":"https://api.github.com/users/mdickinson/followers","following_url":"https://api.github.com/users/mdickinson/following{/other_user}","gists_url":"https://api.github.com/users/mdickinson/gists{/gist_id}","starred_url":"https://api.github.com/users/mdickinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdickinson/subscriptions","organizations_url":"https://api.github.com/users/mdickinson/orgs","repos_url":"https://api.github.com/users/mdickinson/repos","events_url":"https://api.github.com/users/mdickinson/events{/privacy}","received_events_url":"https://api.github.com/users/mdickinson/received_events","type":"User","site_admin":false},"body":"Ditto.","created_at":"2014-10-07T07:49:55Z","updated_at":"2014-10-07T07:49:55Z","html_url":"https://github.com/enthought/traits/pull/205#discussion_r18505000","pull_request_url":"https://api.github.com/repos/enthought/traits/pulls/205","_links":{"self":{"href":"https://api.github.com/repos/enthought/traits/pulls/comments/18505000"},"html":{"href":"https://github.com/enthought/traits/pull/205#discussion_r18505000"},"pull_request":{"href":"https://api.github.com/repos/enthought/traits/pulls/205"}}},"pull_request":{"url":"https://api.github.com/repos/enthought/traits/pulls/205","id":22304588,"html_url":"https://github.com/enthought/traits/pull/205","diff_url":"https://github.com/enthought/traits/pull/205.diff","patch_url":"https://github.com/enthought/traits/pull/205.patch","issue_url":"https://api.github.com/repos/enthought/traits/issues/205","number":205,"state":"open","locked":false,"title":"Feature/validated tuple","user":{"login":"itziakos","id":403930,"avatar_url":"https://avatars.githubusercontent.com/u/403930?v=2","gravatar_id":"","url":"https://api.github.com/users/itziakos","html_url":"https://github.com/itziakos","followers_url":"https://api.github.com/users/itziakos/followers","following_url":"https://api.github.com/users/itziakos/following{/other_user}","gists_url":"https://api.github.com/users/itziakos/gists{/gist_id}","starred_url":"https://api.github.com/users/itziakos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itziakos/subscriptions","organizations_url":"https://api.github.com/users/itziakos/orgs","repos_url":"https://api.github.com/users/itziakos/repos","events_url":"https://api.github.com/users/itziakos/events{/privacy}","received_events_url":"https://api.github.com/users/itziakos/received_events","type":"User","site_admin":false},"body":"This PR adds a new Tuple trait that supports custom validation for the field values in addition to the individual field validation.\r\n\r\n```python\r\n\r\n>>> from traits.api import Int, HasStrictTraits, ValidatedTuple\r\n>>> \r\n>>> class MyClass(HasStrictTraits):\r\n...     value_range = ValidatedTuple(Int(0), Int(1), validation=lambda x: x[0] < x[1])\r\n... \r\n>>>\r\n>>> a = MyClass()\r\n>>> a.value_range\r\n(0, 1)\r\n>>> a.value_range = (2, 1)\r\nTraceback (most recent call last):\r\n  File \"<interactive input>\", line 1, in <module>\r\n  File \"c:\\users\\itziakos\\projects\\meta-geophysics\\geocanopy\\geophysics\\util\\validated_tuple.py\", line 43, in validate\r\n    self.error(object, name, value)\r\n  File \"C:\\Users\\itziakos\\Projects\\traits\\traits\\trait_handlers.py\", line 172, in error\r\n    value )\r\nTraitError: The 'value_range' trait of a MyClass instance must be a tuple of the form: (an integer (int or long), an integer (int or long)) that passes custom validation, but a value of (2, 1) <type 'tuple'> was specified.\r\n>>> a.value_range = (1, 2)\r\n>>> a.value_range\r\n(1, 2)\r\n>>> \r\n```\r\n\r\n","created_at":"2014-10-06T18:41:59Z","updated_at":"2014-10-07T07:49:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cf69ea61a4b8c7b10f64050e5d763d7052d58f1","assignee":{"login":"mdickinson","id":662003,"avatar_url":"https://avatars.githubusercontent.com/u/662003?v=2","gravatar_id":"","url":"https://api.github.com/users/mdickinson","html_url":"https://github.com/mdickinson","followers_url":"https://api.github.com/users/mdickinson/followers","following_url":"https://api.github.com/users/mdickinson/following{/other_user}","gists_url":"https://api.github.com/users/mdickinson/gists{/gist_id}","starred_url":"https://api.github.com/users/mdickinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdickinson/subscriptions","organizations_url":"https://api.github.com/users/mdickinson/orgs","repos_url":"https://api.github.com/users/mdickinson/repos","events_url":"https://api.github.com/users/mdickinson/events{/privacy}","received_events_url":"https://api.github.com/users/mdickinson/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/enthought/traits/pulls/205/commits","review_comments_url":"https://api.github.com/repos/enthought/traits/pulls/205/comments","review_comment_url":"https://api.github.com/repos/enthought/traits/pulls/comments/{number}","comments_url":"https://api.github.com/repos/enthought/traits/issues/205/comments","statuses_url":"https://api.github.com/repos/enthought/traits/statuses/2dc9ad65735b87a7cf5ecb2d8b4fc41fde4b2dc4","head":{"label":"enthought:feature/validated-tuple","ref":"feature/validated-tuple","sha":"2dc9ad65735b87a7cf5ecb2d8b4fc41fde4b2dc4","user":{"login":"enthought","id":539651,"avatar_url":"https://avatars.githubusercontent.com/u/539651?v=2","gravatar_id":"","url":"https://api.github.com/users/enthought","html_url":"https://github.com/enthought","followers_url":"https://api.github.com/users/enthought/followers","following_url":"https://api.github.com/users/enthought/following{/other_user}","gists_url":"https://api.github.com/users/enthought/gists{/gist_id}","starred_url":"https://api.github.com/users/enthought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enthought/subscriptions","organizations_url":"https://api.github.com/users/enthought/orgs","repos_url":"https://api.github.com/users/enthought/repos","events_url":"https://api.github.com/users/enthought/events{/privacy}","received_events_url":"https://api.github.com/users/enthought/received_events","type":"Organization","site_admin":false},"repo":{"id":1301745,"name":"traits","full_name":"enthought/traits","owner":{"login":"enthought","id":539651,"avatar_url":"https://avatars.githubusercontent.com/u/539651?v=2","gravatar_id":"","url":"https://api.github.com/users/enthought","html_url":"https://github.com/enthought","followers_url":"https://api.github.com/users/enthought/followers","following_url":"https://api.github.com/users/enthought/following{/other_user}","gists_url":"https://api.github.com/users/enthought/gists{/gist_id}","starred_url":"https://api.github.com/users/enthought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enthought/subscriptions","organizations_url":"https://api.github.com/users/enthought/orgs","repos_url":"https://api.github.com/users/enthought/repos","events_url":"https://api.github.com/users/enthought/events{/privacy}","received_events_url":"https://api.github.com/users/enthought/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/enthought/traits","description":"Optional type-checking, data dependencies, and event notifications for Python","fork":false,"url":"https://api.github.com/repos/enthought/traits","forks_url":"https://api.github.com/repos/enthought/traits/forks","keys_url":"https://api.github.com/repos/enthought/traits/keys{/key_id}","collaborators_url":"https://api.github.com/repos/enthought/traits/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/enthought/traits/teams","hooks_url":"https://api.github.com/repos/enthought/traits/hooks","issue_events_url":"https://api.github.com/repos/enthought/traits/issues/events{/number}","events_url":"https://api.github.com/repos/enthought/traits/events","assignees_url":"https://api.github.com/repos/enthought/traits/assignees{/user}","branches_url":"https://api.github.com/repos/enthought/traits/branches{/branch}","tags_url":"https://api.github.com/repos/enthought/traits/tags","blobs_url":"https://api.github.com/repos/enthought/traits/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/enthought/traits/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/enthought/traits/git/refs{/sha}","trees_url":"https://api.github.com/repos/enthought/traits/git/trees{/sha}","statuses_url":"https://api.github.com/repos/enthought/traits/statuses/{sha}","languages_url":"https://api.github.com/repos/enthought/traits/languages","stargazers_url":"https://api.github.com/repos/enthought/traits/stargazers","contributors_url":"https://api.github.com/repos/enthought/traits/contributors","subscribers_url":"https://api.github.com/repos/enthought/traits/subscribers","subscription_url":"https://api.github.com/repos/enthought/traits/subscription","commits_url":"https://api.github.com/repos/enthought/traits/commits{/sha}","git_commits_url":"https://api.github.com/repos/enthought/traits/git/commits{/sha}","comments_url":"https://api.github.com/repos/enthought/traits/comments{/number}","issue_comment_url":"https://api.github.com/repos/enthought/traits/issues/comments/{number}","contents_url":"https://api.github.com/repos/enthought/traits/contents/{+path}","compare_url":"https://api.github.com/repos/enthought/traits/compare/{base}...{head}","merges_url":"https://api.github.com/repos/enthought/traits/merges","archive_url":"https://api.github.com/repos/enthought/traits/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/enthought/traits/downloads","issues_url":"https://api.github.com/repos/enthought/traits/issues{/number}","pulls_url":"https://api.github.com/repos/enthought/traits/pulls{/number}","milestones_url":"https://api.github.com/repos/enthought/traits/milestones{/number}","notifications_url":"https://api.github.com/repos/enthought/traits/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/enthought/traits/labels{/name}","releases_url":"https://api.github.com/repos/enthought/traits/releases{/id}","created_at":"2011-01-28T04:46:40Z","updated_at":"2014-10-05T09:52:52Z","pushed_at":"2014-10-07T07:33:39Z","git_url":"git://github.com/enthought/traits.git","ssh_url":"git@github.com:enthought/traits.git","clone_url":"https://github.com/enthought/traits.git","svn_url":"https://github.com/enthought/traits","homepage":"","size":46956,"stargazers_count":101,"watchers_count":101,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":38,"mirror_url":null,"open_issues_count":57,"forks":38,"open_issues":57,"watchers":101,"default_branch":"master"}},"base":{"label":"enthought:master","ref":"master","sha":"1ce982eaa666302da016664c9cf39aa9255ed7fa","user":{"login":"enthought","id":539651,"avatar_url":"https://avatars.githubusercontent.com/u/539651?v=2","gravatar_id":"","url":"https://api.github.com/users/enthought","html_url":"https://github.com/enthought","followers_url":"https://api.github.com/users/enthought/followers","following_url":"https://api.github.com/users/enthought/following{/other_user}","gists_url":"https://api.github.com/users/enthought/gists{/gist_id}","starred_url":"https://api.github.com/users/enthought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enthought/subscriptions","organizations_url":"https://api.github.com/users/enthought/orgs","repos_url":"https://api.github.com/users/enthought/repos","events_url":"https://api.github.com/users/enthought/events{/privacy}","received_events_url":"https://api.github.com/users/enthought/received_events","type":"Organization","site_admin":false},"repo":{"id":1301745,"name":"traits","full_name":"enthought/traits","owner":{"login":"enthought","id":539651,"avatar_url":"https://avatars.githubusercontent.com/u/539651?v=2","gravatar_id":"","url":"https://api.github.com/users/enthought","html_url":"https://github.com/enthought","followers_url":"https://api.github.com/users/enthought/followers","following_url":"https://api.github.com/users/enthought/following{/other_user}","gists_url":"https://api.github.com/users/enthought/gists{/gist_id}","starred_url":"https://api.github.com/users/enthought/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enthought/subscriptions","organizations_url":"https://api.github.com/users/enthought/orgs","repos_url":"https://api.github.com/users/enthought/repos","events_url":"https://api.github.com/users/enthought/events{/privacy}","received_events_url":"https://api.github.com/users/enthought/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/enthought/traits","description":"Optional type-checking, data dependencies, and event notifications for Python","fork":false,"url":"https://api.github.com/repos/enthought/traits","forks_url":"https://api.github.com/repos/enthought/traits/forks","keys_url":"https://api.github.com/repos/enthought/traits/keys{/key_id}","collaborators_url":"https://api.github.com/repos/enthought/traits/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/enthought/traits/teams","hooks_url":"https://api.github.com/repos/enthought/traits/hooks","issue_events_url":"https://api.github.com/repos/enthought/traits/issues/events{/number}","events_url":"https://api.github.com/repos/enthought/traits/events","assignees_url":"https://api.github.com/repos/enthought/traits/assignees{/user}","branches_url":"https://api.github.com/repos/enthought/traits/branches{/branch}","tags_url":"https://api.github.com/repos/enthought/traits/tags","blobs_url":"https://api.github.com/repos/enthought/traits/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/enthought/traits/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/enthought/traits/git/refs{/sha}","trees_url":"https://api.github.com/repos/enthought/traits/git/trees{/sha}","statuses_url":"https://api.github.com/repos/enthought/traits/statuses/{sha}","languages_url":"https://api.github.com/repos/enthought/traits/languages","stargazers_url":"https://api.github.com/repos/enthought/traits/stargazers","contributors_url":"https://api.github.com/repos/enthought/traits/contributors","subscribers_url":"https://api.github.com/repos/enthought/traits/subscribers","subscription_url":"https://api.github.com/repos/enthought/traits/subscription","commits_url":"https://api.github.com/repos/enthought/traits/commits{/sha}","git_commits_url":"https://api.github.com/repos/enthought/traits/git/commits{/sha}","comments_url":"https://api.github.com/repos/enthought/traits/comments{/number}","issue_comment_url":"https://api.github.com/repos/enthought/traits/issues/comments/{number}","contents_url":"https://api.github.com/repos/enthought/traits/contents/{+path}","compare_url":"https://api.github.com/repos/enthought/traits/compare/{base}...{head}","merges_url":"https://api.github.com/repos/enthought/traits/merges","archive_url":"https://api.github.com/repos/enthought/traits/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/enthought/traits/downloads","issues_url":"https://api.github.com/repos/enthought/traits/issues{/number}","pulls_url":"https://api.github.com/repos/enthought/traits/pulls{/number}","milestones_url":"https://api.github.com/repos/enthought/traits/milestones{/number}","notifications_url":"https://api.github.com/repos/enthought/traits/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/enthought/traits/labels{/name}","releases_url":"https://api.github.com/repos/enthought/traits/releases{/id}","created_at":"2011-01-28T04:46:40Z","updated_at":"2014-10-05T09:52:52Z","pushed_at":"2014-10-07T07:33:39Z","git_url":"git://github.com/enthought/traits.git","ssh_url":"git@github.com:enthought/traits.git","clone_url":"https://github.com/enthought/traits.git","svn_url":"https://github.com/enthought/traits","homepage":"","size":46956,"stargazers_count":101,"watchers_count":101,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":38,"mirror_url":null,"open_issues_count":57,"forks":38,"open_issues":57,"watchers":101,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/enthought/traits/pulls/205"},"html":{"href":"https://github.com/enthought/traits/pull/205"},"issue":{"href":"https://api.github.com/repos/enthought/traits/issues/205"},"comments":{"href":"https://api.github.com/repos/enthought/traits/issues/205/comments"},"review_comments":{"href":"https://api.github.com/repos/enthought/traits/pulls/205/comments"},"review_comment":{"href":"https://api.github.com/repos/enthought/traits/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/enthought/traits/pulls/205/commits"},"statuses":{"href":"https://api.github.com/repos/enthought/traits/statuses/2dc9ad65735b87a7cf5ecb2d8b4fc41fde4b2dc4"}}}}