-
Notifications
You must be signed in to change notification settings - Fork 22
Patch create_dispatch #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,8 +11,10 @@ | |||||
| import zlib | ||||||
| from typing import Awaitable, Callable, Optional | ||||||
|
|
||||||
| import github | ||||||
| import requests | ||||||
| from github import Github, UnknownObjectException | ||||||
| from github.GithubObject import NotSet, Opt | ||||||
| from github.Workflow import Workflow | ||||||
| from github.WorkflowRun import WorkflowRun | ||||||
|
|
||||||
|
|
@@ -177,6 +179,35 @@ class GitHubArtifact: | |||||
| _WORKFLOW_FILE_CACHE: dict[str, Workflow] = {} | ||||||
|
|
||||||
|
|
||||||
| def patched_create_dispatch( | ||||||
| workflow: Workflow, | ||||||
| ref: github.Branch.Branch | github.Tag.Tag | github.Commit.Commit | str, | ||||||
| inputs: Opt[dict] = NotSet, | ||||||
| ) -> bool: | ||||||
| """ | ||||||
| :calls: `POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches <https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event>`_ | ||||||
| """ | ||||||
| assert ( | ||||||
| isinstance(ref, github.Branch.Branch) | ||||||
| or isinstance(ref, github.Tag.Tag) | ||||||
| or isinstance(ref, github.Commit.Commit) | ||||||
| or isinstance(ref, str) | ||||||
| ), ref | ||||||
| assert inputs is NotSet or isinstance(inputs, dict), inputs | ||||||
| if isinstance(ref, github.Branch.Branch): | ||||||
| ref = ref.name | ||||||
| elif isinstance(ref, github.Commit.Commit): | ||||||
| ref = ref.sha | ||||||
| elif isinstance(ref, github.Tag.Tag): | ||||||
| ref = ref.name | ||||||
| if inputs is NotSet: | ||||||
| inputs = {} | ||||||
| status, _, _ = workflow._requester.requestJson( | ||||||
| "POST", f"{workflow.url}/dispatches", input={"ref": ref, "inputs": inputs} | ||||||
| ) | ||||||
| return status == 200 | ||||||
|
||||||
| return status == 200 | |
| return status in (200, 204) |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The noqa: E501 comment suppresses line-too-long warnings, but this line appears to be under the 100-character limit specified in .ruff.toml. Consider removing this comment if the line length is within the project's limits.
| ) # noqa: E501 | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring should explain why this patched version exists and what issue it addresses. Consider adding a note that this patches the PyGithub library to handle GitHub API's change from returning 204 to 200 status codes.