def protect(self, enforcement=None, status_checks=None):
        previous_values = self.protection['required_status_checks']
        if enforcement is None:
            enforcement = previous_values['enforcement_level']
        if status_checks is None:
            status_checks = previous_values['contexts']

        edit = {'protection': {'enabled': True, 'required_status_checks': {
            'enforcement_level': enforcement, 'contexts': status_checks}}}
        json = self._json(self._patch(self._api, data=dumps(edit),
                                      headers=self.PREVIEW_HEADERS), 200)
        self._update_attributes(json)
        return True
Enable force push protection and configure status check enforcement.
dataset/ETHPy150Open sigmavirus24/github3.py/github3/repos/branch.py/Branch.protect