Skip to content

Branch.protect cannot work #837

@seveas

Description

@seveas

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.

Version Information

Please provide:

  • The version of Python you're using: 2.7

  • The version of pip you used to install github3.py: n/a

  • The version of github3.py, requests, uritemplate, and dateutil installed: code checked against github3.py ~~~master~~~ develop. Other versions not relevant

Minimum Reproducible Example

repository.protect(enforcement='everyone', status_checks=['foo'])

Exception information

What is exceptional about what you're seeing versus what you expected to see.

  File "/home/dennis/code/git-spindle/lib/gitspindle/github.py", line 1094, in protect
    status_checks=(opts['--status-checks'] or '').split(','))
  File "/usr/lib/python2.7/dist-packages/github3/decorators.py", line 30, in auth_wrapper
    return func(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/github3/repos/branch.py", line 97, in protect
    previous_values = self.protection['required_status_checks']
TypeError: 'instancemethod' object has no attribute '__getitem__'

And when changing to call the protection() method:

  File "/home/dennis/code/git-spindle/lib/gitspindle/github.py", line 1094, in protect
    status_checks=(opts['--status-checks'] or '').split(','))
  File "/usr/lib/python2.7/dist-packages/github3/decorators.py", line 30, in auth_wrapper
    return func(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/github3/repos/branch.py", line 97, in protect
    previous_values = self.protection()['required_status_checks']
  File "/usr/lib/python2.7/dist-packages/github3/decorators.py", line 30, in auth_wrapper
    return func(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/github3/repos/branch.py", line 73, in protection
    json = self._json(resp, 200)
  File "/usr/lib/python2.7/dist-packages/github3/models.py", line 156, in _json
    raise exceptions.error_for(response)
github3.exceptions.NotFoundError: 404 Branch not protected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions