{"action":"created","issue":{"url":"https://api.github.com/repos/sigmavirus24/github3.py/issues/837","repository_url":"https://api.github.com/repos/sigmavirus24/github3.py","labels_url":"https://api.github.com/repos/sigmavirus24/github3.py/issues/837/labels{/name}","comments_url":"https://api.github.com/repos/sigmavirus24/github3.py/issues/837/comments","events_url":"https://api.github.com/repos/sigmavirus24/github3.py/issues/837/events","html_url":"https://github.com/sigmavirus24/github3.py/issues/837","id":316428948,"number":837,"title":"Branch.protect cannot work","user":{"login":"seveas","id":200649,"avatar_url":"https://avatars3.githubusercontent.com/u/200649?v=4","gravatar_id":"","url":"https://api.github.com/users/seveas","html_url":"https://github.com/seveas","followers_url":"https://api.github.com/users/seveas/followers","following_url":"https://api.github.com/users/seveas/following{/other_user}","gists_url":"https://api.github.com/users/seveas/gists{/gist_id}","starred_url":"https://api.github.com/users/seveas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seveas/subscriptions","organizations_url":"https://api.github.com/users/seveas/orgs","repos_url":"https://api.github.com/users/seveas/repos","events_url":"https://api.github.com/users/seveas/events{/privacy}","received_events_url":"https://api.github.com/users/seveas/received_events","type":"User","site_admin":true},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-20T22:26:49Z","updated_at":"2018-04-22T18:08:33Z","closed_at":"2018-04-22T18:08:33Z","author_association":"COLLABORATOR","body":"It checks self.protection as if it's a dict, but it's a method. Simply calling the method won't work either, as the api 404's when the branch is not protected.\r\n\r\n## Version Information\r\n\r\nPlease provide:\r\n\r\n- The version of Python you're using: 2.7\r\n\r\n- The version of pip you used to install github3.py: n/a\r\n\r\n- The version of github3.py, requests, uritemplate, and dateutil installed: code checked against github3.py ~~~master~~~ develop. Other versions not relevant\r\n\r\n## Minimum Reproducible Example\r\n\r\n```\r\nrepository.protect(enforcement='everyone', status_checks=['foo'])\r\n```\r\n\r\n\r\n## Exception information\r\n\r\nWhat is exceptional about what you're seeing versus what you expected to see.\r\n\r\n```\r\n  File \"/home/dennis/code/git-spindle/lib/gitspindle/github.py\", line 1094, in protect\r\n    status_checks=(opts['--status-checks'] or '').split(','))\r\n  File \"/usr/lib/python2.7/dist-packages/github3/decorators.py\", line 30, in auth_wrapper\r\n    return func(self, *args, **kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/github3/repos/branch.py\", line 97, in protect\r\n    previous_values = self.protection['required_status_checks']\r\nTypeError: 'instancemethod' object has no attribute '__getitem__'\r\n```\r\nAnd when changing to call the protection() method:\r\n\r\n```\r\n  File \"/home/dennis/code/git-spindle/lib/gitspindle/github.py\", line 1094, in protect\r\n    status_checks=(opts['--status-checks'] or '').split(','))\r\n  File \"/usr/lib/python2.7/dist-packages/github3/decorators.py\", line 30, in auth_wrapper\r\n    return func(self, *args, **kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/github3/repos/branch.py\", line 97, in protect\r\n    previous_values = self.protection()['required_status_checks']\r\n  File \"/usr/lib/python2.7/dist-packages/github3/decorators.py\", line 30, in auth_wrapper\r\n    return func(self, *args, **kwargs)\r\n  File \"/usr/lib/python2.7/dist-packages/github3/repos/branch.py\", line 73, in protection\r\n    json = self._json(resp, 200)\r\n  File \"/usr/lib/python2.7/dist-packages/github3/models.py\", line 156, in _json\r\n    raise exceptions.error_for(response)\r\ngithub3.exceptions.NotFoundError: 404 Branch not protected\r\n\r\n```\r\n\r\n<!-- links -->\r\n[search]: https://github.com/sigmavirus24/github3.py/issues?utf8=%E2%9C%93&q=is%3Aissue\r\n"},"comment":{"url":"https://api.github.com/repos/sigmavirus24/github3.py/issues/comments/383400740","html_url":"https://github.com/sigmavirus24/github3.py/issues/837#issuecomment-383400740","issue_url":"https://api.github.com/repos/sigmavirus24/github3.py/issues/837","id":383400740,"user":{"login":"seveas","id":200649,"avatar_url":"https://avatars3.githubusercontent.com/u/200649?v=4","gravatar_id":"","url":"https://api.github.com/users/seveas","html_url":"https://github.com/seveas","followers_url":"https://api.github.com/users/seveas/followers","following_url":"https://api.github.com/users/seveas/following{/other_user}","gists_url":"https://api.github.com/users/seveas/gists{/gist_id}","starred_url":"https://api.github.com/users/seveas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seveas/subscriptions","organizations_url":"https://api.github.com/users/seveas/orgs","repos_url":"https://api.github.com/users/seveas/repos","events_url":"https://api.github.com/users/seveas/events{/privacy}","received_events_url":"https://api.github.com/users/seveas/received_events","type":"User","site_admin":true},"created_at":"2018-04-22T18:08:33Z","updated_at":"2018-04-22T18:08:33Z","author_association":"COLLABORATOR","body":"Ah, that explains. I'll just close this issue then and test the new code. Thanks!"}}
{"actor":{"display_login":"seveas"}}