{"action":"created","comment":{"url":"https://api.github.com/repos/ipython/traitlets/pulls/comments/45514468","id":45514468,"diff_hunk":"@@ -650,43 +650,35 @@ class MetaHasDescriptors(type):\n     \"\"\"\n \n     def __new__(mcls, name, bases, classdict):\n-        \"\"\"Create the HasDescriptors class.\n-\n-        This sets :attr:`name` attribute of each descriptor in the class dict.\n-        \"\"\"\n+        \"\"\"Create the HasDescriptors class.\"\"\"\n         for k, v in iteritems(classdict):\n-            if isinstance(v, BaseDescriptor):\n-                v.name = k\n-\n             # ----------------------------------------------------------------\n             # Support of deprecated behavior allowing for TraitType types\n             # to be used instead of TraitType instances.\n-            elif inspect.isclass(v):\n-                if issubclass(v, TraitType):\n-                    warn(\"Traits should be given as instances, not types (for example, `Int()`, not `Int`)\",\n-                         DeprecationWarning, stacklevel=2)\n-                    vinst = v()\n-                    vinst.name = k\n-                    classdict[k] = vinst\n+            if inspect.isclass(v) and issubclass(v, TraitType):\n+                warn(\"Traits should be given as instances, not types (for example, `Int()`, not `Int`)\",\n+                     DeprecationWarning, stacklevel=2)\n+                classdict[k] = v()\n             # ----------------------------------------------------------------\n \n         return super(MetaHasDescriptors, mcls).__new__(mcls, name, bases, classdict)\n \n     def __init__(cls, name, bases, classdict):\n-        \"\"\"Finish initializing the HasDescriptors class.\n-\n-        This sets the :attr:`this_class` attribute of each BaseDescriptor in the\n-        class dict to the newly created class ``cls``.\n-        \"\"\"\n-        for k, v in iteritems(classdict):\n-            if isinstance(v, BaseDescriptor):\n-                v.this_class = cls\n-        cls.setup_class()\n+        \"\"\"Finish initializing the HasDescriptors class.\"\"\"\n         super(MetaHasDescriptors, cls).__init__(name, bases, classdict)\n+        cls.setup_class()","path":"traitlets/traitlets.py","position":43,"original_position":43,"commit_id":"91f98d31f17bb25d039b170e11490020119fe120","original_commit_id":"91f98d31f17bb25d039b170e11490020119fe120","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":"As long as it's not iterating over `cls.__dict__` it should work. Decided to keep the signature clean since I didn't think a shallow copy of the dict would be terribly intensive (could be wrong though).","created_at":"2015-11-20T20:28:23Z","updated_at":"2015-11-20T20:28:23Z","html_url":"https://github.com/ipython/traitlets/pull/129#discussion_r45514468","pull_request_url":"https://api.github.com/repos/ipython/traitlets/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/comments/45514468"},"html":{"href":"https://github.com/ipython/traitlets/pull/129#discussion_r45514468"},"pull_request":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/ipython/traitlets/pulls/129","id":50737398,"html_url":"https://github.com/ipython/traitlets/pull/129","diff_url":"https://github.com/ipython/traitlets/pull/129.diff","patch_url":"https://github.com/ipython/traitlets/pull/129.patch","issue_url":"https://api.github.com/repos/ipython/traitlets/issues/129","number":129,"state":"open","locked":false,"title":"Streamline Class Setup Logic in MetaHasDescriptors","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":"Reduces the number of times the metaclass must iterate over the classdict, and uses a copy of `cls.__dict__` when iterating in `setup_class` so that changes in the size of the dict, which could potentially be caused by the `class_init` methods of descriptors, won't throw errors.","created_at":"2015-11-15T01:56:04Z","updated_at":"2015-11-20T20:28:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f42aa8b0204fa1c8e24edb9acf7f0c16890c122b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ipython/traitlets/pulls/129/commits","review_comments_url":"https://api.github.com/repos/ipython/traitlets/pulls/129/comments","review_comment_url":"https://api.github.com/repos/ipython/traitlets/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ipython/traitlets/issues/129/comments","statuses_url":"https://api.github.com/repos/ipython/traitlets/statuses/91f98d31f17bb25d039b170e11490020119fe120","head":{"label":"rmorshea:streamline_metaclass","ref":"streamline_metaclass","sha":"91f98d31f17bb25d039b170e11490020119fe120","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}","created_at":"2015-06-15T17:48:57Z","updated_at":"2015-06-15T17:48:58Z","pushed_at":"2015-11-20T00:04:22Z","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":836,"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":"fb2798498787151cd85d66bfc1962e61f0ac3a67","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}","created_at":"2013-12-06T20:45:45Z","updated_at":"2015-11-10T06:54:01Z","pushed_at":"2015-11-20T00:04:23Z","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":2534,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":20,"forks":33,"open_issues":20,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/129"},"html":{"href":"https://github.com/ipython/traitlets/pull/129"},"issue":{"href":"https://api.github.com/repos/ipython/traitlets/issues/129"},"comments":{"href":"https://api.github.com/repos/ipython/traitlets/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ipython/traitlets/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/ipython/traitlets/statuses/91f98d31f17bb25d039b170e11490020119fe120"}}}}