MCPcopy Index your code
hub / github.com/PyGithub/PyGithub / edit_protection

Method edit_protection

github/Branch.py:162–352  ·  view source on GitHub ↗

:calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection `_ NOTE: The GitHub API groups strict and contexts together, both must be submitted. Take care to pass both as arguments even if only one i

(
        self,
        strict: Opt[bool] = NotSet,
        contexts: Opt[list[str]] = NotSet,
        enforce_admins: Opt[bool] = NotSet,
        dismissal_users: Opt[list[str]] = NotSet,
        dismissal_teams: Opt[list[str]] = NotSet,
        dismissal_apps: Opt[list[str]] = NotSet,
        dismiss_stale_reviews: Opt[bool] = NotSet,
        require_code_owner_reviews: Opt[bool] = NotSet,
        required_approving_review_count: Opt[int] = NotSet,
        user_push_restrictions: Opt[list[str]] = NotSet,
        team_push_restrictions: Opt[list[str]] = NotSet,
        app_push_restrictions: Opt[list[str]] = NotSet,
        required_linear_history: Opt[bool] = NotSet,
        allow_force_pushes: Opt[bool] = NotSet,
        required_conversation_resolution: Opt[bool] = NotSet,
        lock_branch: Opt[bool] = NotSet,
        allow_fork_syncing: Opt[bool] = NotSet,
        users_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
        teams_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
        apps_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
        block_creations: Opt[bool] = NotSet,
        require_last_push_approval: Opt[bool] = NotSet,
        allow_deletions: Opt[bool] = NotSet,
        checks: Opt[list[str | tuple[str, int]]] = NotSet,
    )

Source from the content-addressed store, hash-verified

160 return github.BranchProtection.BranchProtection(self._requester, headers, data, completed=True)
161
162 def edit_protection(
163 self,
164 strict: Opt[bool] = NotSet,
165 contexts: Opt[list[str]] = NotSet,
166 enforce_admins: Opt[bool] = NotSet,
167 dismissal_users: Opt[list[str]] = NotSet,
168 dismissal_teams: Opt[list[str]] = NotSet,
169 dismissal_apps: Opt[list[str]] = NotSet,
170 dismiss_stale_reviews: Opt[bool] = NotSet,
171 require_code_owner_reviews: Opt[bool] = NotSet,
172 required_approving_review_count: Opt[int] = NotSet,
173 user_push_restrictions: Opt[list[str]] = NotSet,
174 team_push_restrictions: Opt[list[str]] = NotSet,
175 app_push_restrictions: Opt[list[str]] = NotSet,
176 required_linear_history: Opt[bool] = NotSet,
177 allow_force_pushes: Opt[bool] = NotSet,
178 required_conversation_resolution: Opt[bool] = NotSet,
179 lock_branch: Opt[bool] = NotSet,
180 allow_fork_syncing: Opt[bool] = NotSet,
181 users_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
182 teams_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
183 apps_bypass_pull_request_allowances: Opt[list[str]] = NotSet,
184 block_creations: Opt[bool] = NotSet,
185 require_last_push_approval: Opt[bool] = NotSet,
186 allow_deletions: Opt[bool] = NotSet,
187 checks: Opt[list[str | tuple[str, int]]] = NotSet,
188 ) -> BranchProtection:
189 """
190 :calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection <https://docs.github.com/en/rest/reference/repos#get-branch-protection>`_
191
192 NOTE: The GitHub API groups strict and contexts together, both must
193 be submitted. Take care to pass both as arguments even if only one is
194 changing. Use edit_required_status_checks() to avoid this.
195 """
196 assert is_optional(strict, bool), strict
197 assert is_optional_list(contexts, str), contexts
198 assert is_optional(enforce_admins, bool), enforce_admins
199 assert is_optional_list(dismissal_users, str), dismissal_users
200 assert is_optional_list(dismissal_teams, str), dismissal_teams
201 assert is_optional_list(dismissal_apps, str), dismissal_apps
202 assert is_optional(dismiss_stale_reviews, bool), dismiss_stale_reviews
203 assert is_optional(require_code_owner_reviews, bool), require_code_owner_reviews
204 assert is_optional(required_approving_review_count, int), required_approving_review_count
205 assert is_optional(required_linear_history, bool), required_linear_history
206 assert is_optional(allow_force_pushes, bool), allow_force_pushes
207 assert is_optional(required_conversation_resolution, bool), required_conversation_resolution
208 assert is_optional(lock_branch, bool), lock_branch
209 assert is_optional(allow_fork_syncing, bool), allow_fork_syncing
210 assert is_optional_list(users_bypass_pull_request_allowances, str), users_bypass_pull_request_allowances
211 assert is_optional_list(teams_bypass_pull_request_allowances, str), teams_bypass_pull_request_allowances
212 assert is_optional_list(apps_bypass_pull_request_allowances, str), apps_bypass_pull_request_allowances
213 assert is_optional(require_last_push_approval, bool), require_last_push_approval
214 assert is_optional(allow_deletions, bool), allow_deletions
215 assert is_optional_list(checks, (str, tuple)), checks
216 if is_defined(checks):
217 assert all(not isinstance(check, tuple) or list(map(type, check)) == [str, int] for check in checks), checks
218
219 post_parameters: dict[str, Any] = {}

Calls 5

is_optionalFunction · 0.90
is_optional_listFunction · 0.90
is_definedFunction · 0.90
is_undefinedFunction · 0.90
requestJsonAndCheckMethod · 0.80

Tested by

no test coverage detected