{"action":"created","comment":{"url":"https://api.github.com/repos/ipython/traitlets/pulls/comments/69272670","id":69272670,"diff_hunk":"@@ -1129,37 +1182,38 @@ def hold(change):\n                         self.notify_change(change)\n \n     def _notify_trait(self, name, old_value, new_value):\n-        self.notify_change(Bunch(\n+        self.notify_change(Change(\n             name=name,\n             old=old_value,\n             new=new_value,\n             owner=self,\n-            type='change',\n         ))\n \n     def notify_change(self, change):\n-        if not isinstance(change, Bunch):\n+        if not isinstance(change, EventReport):\n             # cast to bunch if given a dict\n-            change = Bunch(change)\n-        name, type = change.name, change.type\n+            change = EventReport(change)\n \n         callables = []\n-        callables.extend(self._trait_notifiers.get(name, {}).get(type, []))\n-        callables.extend(self._trait_notifiers.get(name, {}).get(All, []))\n-        callables.extend(self._trait_notifiers.get(All, {}).get(type, []))\n-        callables.extend(self._trait_notifiers.get(All, {}).get(All, []))\n+        if 'name' in change:\n+            # name is not gaurenteed to be in the event report","path":"traitlets/traitlets.py","position":170,"original_position":170,"commit_id":"be1c268391edc290d53106d0f88da5af07ed7483","original_commit_id":"be1c268391edc290d53106d0f88da5af07ed7483","user":{"login":"minrk","id":151929,"avatar_url":"https://avatars.githubusercontent.com/u/151929?v=3","gravatar_id":"","url":"https://api.github.com/users/minrk","html_url":"https://github.com/minrk","followers_url":"https://api.github.com/users/minrk/followers","following_url":"https://api.github.com/users/minrk/following{/other_user}","gists_url":"https://api.github.com/users/minrk/gists{/gist_id}","starred_url":"https://api.github.com/users/minrk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minrk/subscriptions","organizations_url":"https://api.github.com/users/minrk/orgs","repos_url":"https://api.github.com/users/minrk/repos","events_url":"https://api.github.com/users/minrk/events{/privacy}","received_events_url":"https://api.github.com/users/minrk/received_events","type":"User","site_admin":false},"body":"Why/how is name not guaranteed? It's assumed two lines above here in master, so this method would error if name were ever left undefined.","created_at":"2016-07-01T09:25:02Z","updated_at":"2016-07-01T09:25:02Z","html_url":"https://github.com/ipython/traitlets/pull/251#discussion_r69272670","pull_request_url":"https://api.github.com/repos/ipython/traitlets/pulls/251","_links":{"self":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/comments/69272670"},"html":{"href":"https://github.com/ipython/traitlets/pull/251#discussion_r69272670"},"pull_request":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/251"}}},"pull_request":{"url":"https://api.github.com/repos/ipython/traitlets/pulls/251","id":75922181,"html_url":"https://github.com/ipython/traitlets/pull/251","diff_url":"https://github.com/ipython/traitlets/pull/251.diff","patch_url":"https://github.com/ipython/traitlets/pull/251.patch","issue_url":"https://api.github.com/repos/ipython/traitlets/issues/251","number":251,"state":"open","locked":false,"title":"Add an EventReport class","user":{"login":"rmorshea","id":4041990,"avatar_url":"https://avatars.githubusercontent.com/u/4041990?v=3","gravatar_id":"","url":"https://api.github.com/users/rmorshea","html_url":"https://github.com/rmorshea","followers_url":"https://api.github.com/users/rmorshea/followers","following_url":"https://api.github.com/users/rmorshea/following{/other_user}","gists_url":"https://api.github.com/users/rmorshea/gists{/gist_id}","starred_url":"https://api.github.com/users/rmorshea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmorshea/subscriptions","organizations_url":"https://api.github.com/users/rmorshea/orgs","repos_url":"https://api.github.com/users/rmorshea/repos","events_url":"https://api.github.com/users/rmorshea/events{/privacy}","received_events_url":"https://api.github.com/users/rmorshea/received_events","type":"User","site_admin":false},"body":"The `EventReport` class provides a base class for all `FrozenBunch` instances being passed to event callbacks. At minimum, a report has a `'type'` key/attribute indicating the type of event being reported. Outside of this, it's up to subclasses to add more information.\r\n\r\nBenefits of an `EventReport` class:\r\n\r\n1. Uniformity can be enforced across traitlets callbacks\r\n2. Subclasses can set which keys/attributes they contain\r\n3. The report instances themselves are \"frozen\" bunches\r\n\r\n*note: we implement a `FrozenBunch` rather than a `Bunch` class (still inherits from `dict`)\r\n\r\nThis will break any usages of Traitlets that attempt to modify event reports. Ultimately this shouldn't ever happen, but it may be a significant enough problem that the reports will need to be mutable. Making them mutable would be unfortunate though, since an error caused by a notification that accidently modified a report would be hard to trace.\r\n\r\nAt the very least it would be beneficial to implement an `EventReport` that has a `'type'`:\r\n\r\n```python\r\nclass EventReport(Bunch):\r\n\tdef __init__(self, type, **kwargs):\r\n\t\tsuper(Bunch, self).__init__(type=type, **kwargs)\r\n```\r\n","created_at":"2016-07-01T03:18:38Z","updated_at":"2016-07-01T09:25:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77b097b9b9369100dbf0965b7f0a6c991198a80a","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ipython/traitlets/milestones/5","html_url":"https://github.com/ipython/traitlets/milestones/5.0","labels_url":"https://api.github.com/repos/ipython/traitlets/milestones/5/labels","id":1185702,"number":5,"title":"5.0","description":"","creator":{"login":"takluyver","id":327925,"avatar_url":"https://avatars.githubusercontent.com/u/327925?v=3","gravatar_id":"","url":"https://api.github.com/users/takluyver","html_url":"https://github.com/takluyver","followers_url":"https://api.github.com/users/takluyver/followers","following_url":"https://api.github.com/users/takluyver/following{/other_user}","gists_url":"https://api.github.com/users/takluyver/gists{/gist_id}","starred_url":"https://api.github.com/users/takluyver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takluyver/subscriptions","organizations_url":"https://api.github.com/users/takluyver/orgs","repos_url":"https://api.github.com/users/takluyver/repos","events_url":"https://api.github.com/users/takluyver/events{/privacy}","received_events_url":"https://api.github.com/users/takluyver/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2015-06-29T17:18:20Z","updated_at":"2016-07-01T09:11:58Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/ipython/traitlets/pulls/251/commits","review_comments_url":"https://api.github.com/repos/ipython/traitlets/pulls/251/comments","review_comment_url":"https://api.github.com/repos/ipython/traitlets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ipython/traitlets/issues/251/comments","statuses_url":"https://api.github.com/repos/ipython/traitlets/statuses/be1c268391edc290d53106d0f88da5af07ed7483","head":{"label":"rmorshea:bunch_types","ref":"bunch_types","sha":"be1c268391edc290d53106d0f88da5af07ed7483","user":{"login":"rmorshea","id":4041990,"avatar_url":"https://avatars.githubusercontent.com/u/4041990?v=3","gravatar_id":"","url":"https://api.github.com/users/rmorshea","html_url":"https://github.com/rmorshea","followers_url":"https://api.github.com/users/rmorshea/followers","following_url":"https://api.github.com/users/rmorshea/following{/other_user}","gists_url":"https://api.github.com/users/rmorshea/gists{/gist_id}","starred_url":"https://api.github.com/users/rmorshea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmorshea/subscriptions","organizations_url":"https://api.github.com/users/rmorshea/orgs","repos_url":"https://api.github.com/users/rmorshea/repos","events_url":"https://api.github.com/users/rmorshea/events{/privacy}","received_events_url":"https://api.github.com/users/rmorshea/received_events","type":"User","site_admin":false},"repo":{"id":37481051,"name":"traitlets","full_name":"rmorshea/traitlets","owner":{"login":"rmorshea","id":4041990,"avatar_url":"https://avatars.githubusercontent.com/u/4041990?v=3","gravatar_id":"","url":"https://api.github.com/users/rmorshea","html_url":"https://github.com/rmorshea","followers_url":"https://api.github.com/users/rmorshea/followers","following_url":"https://api.github.com/users/rmorshea/following{/other_user}","gists_url":"https://api.github.com/users/rmorshea/gists{/gist_id}","starred_url":"https://api.github.com/users/rmorshea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmorshea/subscriptions","organizations_url":"https://api.github.com/users/rmorshea/orgs","repos_url":"https://api.github.com/users/rmorshea/repos","events_url":"https://api.github.com/users/rmorshea/events{/privacy}","received_events_url":"https://api.github.com/users/rmorshea/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rmorshea/traitlets","description":"A lightweight Traits like module","fork":true,"url":"https://api.github.com/repos/rmorshea/traitlets","forks_url":"https://api.github.com/repos/rmorshea/traitlets/forks","keys_url":"https://api.github.com/repos/rmorshea/traitlets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rmorshea/traitlets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rmorshea/traitlets/teams","hooks_url":"https://api.github.com/repos/rmorshea/traitlets/hooks","issue_events_url":"https://api.github.com/repos/rmorshea/traitlets/issues/events{/number}","events_url":"https://api.github.com/repos/rmorshea/traitlets/events","assignees_url":"https://api.github.com/repos/rmorshea/traitlets/assignees{/user}","branches_url":"https://api.github.com/repos/rmorshea/traitlets/branches{/branch}","tags_url":"https://api.github.com/repos/rmorshea/traitlets/tags","blobs_url":"https://api.github.com/repos/rmorshea/traitlets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rmorshea/traitlets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rmorshea/traitlets/git/refs{/sha}","trees_url":"https://api.github.com/repos/rmorshea/traitlets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rmorshea/traitlets/statuses/{sha}","languages_url":"https://api.github.com/repos/rmorshea/traitlets/languages","stargazers_url":"https://api.github.com/repos/rmorshea/traitlets/stargazers","contributors_url":"https://api.github.com/repos/rmorshea/traitlets/contributors","subscribers_url":"https://api.github.com/repos/rmorshea/traitlets/subscribers","subscription_url":"https://api.github.com/repos/rmorshea/traitlets/subscription","commits_url":"https://api.github.com/repos/rmorshea/traitlets/commits{/sha}","git_commits_url":"https://api.github.com/repos/rmorshea/traitlets/git/commits{/sha}","comments_url":"https://api.github.com/repos/rmorshea/traitlets/comments{/number}","issue_comment_url":"https://api.github.com/repos/rmorshea/traitlets/issues/comments{/number}","contents_url":"https://api.github.com/repos/rmorshea/traitlets/contents/{+path}","compare_url":"https://api.github.com/repos/rmorshea/traitlets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rmorshea/traitlets/merges","archive_url":"https://api.github.com/repos/rmorshea/traitlets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rmorshea/traitlets/downloads","issues_url":"https://api.github.com/repos/rmorshea/traitlets/issues{/number}","pulls_url":"https://api.github.com/repos/rmorshea/traitlets/pulls{/number}","milestones_url":"https://api.github.com/repos/rmorshea/traitlets/milestones{/number}","notifications_url":"https://api.github.com/repos/rmorshea/traitlets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rmorshea/traitlets/labels{/name}","releases_url":"https://api.github.com/repos/rmorshea/traitlets/releases{/id}","deployments_url":"https://api.github.com/repos/rmorshea/traitlets/deployments","created_at":"2015-06-15T17:48:57Z","updated_at":"2016-06-03T21:44:02Z","pushed_at":"2016-07-01T07:50:44Z","git_url":"git://github.com/rmorshea/traitlets.git","ssh_url":"git@github.com:rmorshea/traitlets.git","clone_url":"https://github.com/rmorshea/traitlets.git","svn_url":"https://github.com/rmorshea/traitlets","homepage":null,"size":1129,"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":"ipython:master","ref":"master","sha":"74eef4d1780a2efe98fe72459ccaf6d10f727721","user":{"login":"ipython","id":230453,"avatar_url":"https://avatars.githubusercontent.com/u/230453?v=3","gravatar_id":"","url":"https://api.github.com/users/ipython","html_url":"https://github.com/ipython","followers_url":"https://api.github.com/users/ipython/followers","following_url":"https://api.github.com/users/ipython/following{/other_user}","gists_url":"https://api.github.com/users/ipython/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython/subscriptions","organizations_url":"https://api.github.com/users/ipython/orgs","repos_url":"https://api.github.com/users/ipython/repos","events_url":"https://api.github.com/users/ipython/events{/privacy}","received_events_url":"https://api.github.com/users/ipython/received_events","type":"Organization","site_admin":false},"repo":{"id":14993021,"name":"traitlets","full_name":"ipython/traitlets","owner":{"login":"ipython","id":230453,"avatar_url":"https://avatars.githubusercontent.com/u/230453?v=3","gravatar_id":"","url":"https://api.github.com/users/ipython","html_url":"https://github.com/ipython","followers_url":"https://api.github.com/users/ipython/followers","following_url":"https://api.github.com/users/ipython/following{/other_user}","gists_url":"https://api.github.com/users/ipython/gists{/gist_id}","starred_url":"https://api.github.com/users/ipython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipython/subscriptions","organizations_url":"https://api.github.com/users/ipython/orgs","repos_url":"https://api.github.com/users/ipython/repos","events_url":"https://api.github.com/users/ipython/events{/privacy}","received_events_url":"https://api.github.com/users/ipython/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ipython/traitlets","description":"A lightweight Traits like module","fork":false,"url":"https://api.github.com/repos/ipython/traitlets","forks_url":"https://api.github.com/repos/ipython/traitlets/forks","keys_url":"https://api.github.com/repos/ipython/traitlets/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ipython/traitlets/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ipython/traitlets/teams","hooks_url":"https://api.github.com/repos/ipython/traitlets/hooks","issue_events_url":"https://api.github.com/repos/ipython/traitlets/issues/events{/number}","events_url":"https://api.github.com/repos/ipython/traitlets/events","assignees_url":"https://api.github.com/repos/ipython/traitlets/assignees{/user}","branches_url":"https://api.github.com/repos/ipython/traitlets/branches{/branch}","tags_url":"https://api.github.com/repos/ipython/traitlets/tags","blobs_url":"https://api.github.com/repos/ipython/traitlets/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ipython/traitlets/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ipython/traitlets/git/refs{/sha}","trees_url":"https://api.github.com/repos/ipython/traitlets/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ipython/traitlets/statuses/{sha}","languages_url":"https://api.github.com/repos/ipython/traitlets/languages","stargazers_url":"https://api.github.com/repos/ipython/traitlets/stargazers","contributors_url":"https://api.github.com/repos/ipython/traitlets/contributors","subscribers_url":"https://api.github.com/repos/ipython/traitlets/subscribers","subscription_url":"https://api.github.com/repos/ipython/traitlets/subscription","commits_url":"https://api.github.com/repos/ipython/traitlets/commits{/sha}","git_commits_url":"https://api.github.com/repos/ipython/traitlets/git/commits{/sha}","comments_url":"https://api.github.com/repos/ipython/traitlets/comments{/number}","issue_comment_url":"https://api.github.com/repos/ipython/traitlets/issues/comments{/number}","contents_url":"https://api.github.com/repos/ipython/traitlets/contents/{+path}","compare_url":"https://api.github.com/repos/ipython/traitlets/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ipython/traitlets/merges","archive_url":"https://api.github.com/repos/ipython/traitlets/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ipython/traitlets/downloads","issues_url":"https://api.github.com/repos/ipython/traitlets/issues{/number}","pulls_url":"https://api.github.com/repos/ipython/traitlets/pulls{/number}","milestones_url":"https://api.github.com/repos/ipython/traitlets/milestones{/number}","notifications_url":"https://api.github.com/repos/ipython/traitlets/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ipython/traitlets/labels{/name}","releases_url":"https://api.github.com/repos/ipython/traitlets/releases{/id}","deployments_url":"https://api.github.com/repos/ipython/traitlets/deployments","created_at":"2013-12-06T20:45:45Z","updated_at":"2016-06-29T09:25:55Z","pushed_at":"2016-07-01T09:20:14Z","git_url":"git://github.com/ipython/traitlets.git","ssh_url":"git@github.com:ipython/traitlets.git","clone_url":"https://github.com/ipython/traitlets.git","svn_url":"https://github.com/ipython/traitlets","homepage":"http://traitlets.readthedocs.org/","size":2098,"stargazers_count":56,"watchers_count":56,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":40,"forks":49,"open_issues":40,"watchers":56,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/251"},"html":{"href":"https://github.com/ipython/traitlets/pull/251"},"issue":{"href":"https://api.github.com/repos/ipython/traitlets/issues/251"},"comments":{"href":"https://api.github.com/repos/ipython/traitlets/issues/251/comments"},"review_comments":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/251/comments"},"review_comment":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/251/commits"},"statuses":{"href":"https://api.github.com/repos/ipython/traitlets/statuses/be1c268391edc290d53106d0f88da5af07ed7483"}}}}
{"actor":{"display_login":"minrk"}}