Model GitHub API enum fields as StrEnum in the async client#24316
Draft
HadhemiDD wants to merge 7 commits into
Draft
Model GitHub API enum fields as StrEnum in the async client#24316HadhemiDD wants to merge 7 commits into
HadhemiDD wants to merge 7 commits into
Conversation
Convert response-model fields the GitHub OpenAPI description (pinned to GITHUB_API_VERSION 2022-11-28) declares as an enum into StrEnums, per the github_async guidelines: - PullRequestState (open, closed) for PullRequest.state - WorkflowJobStatus / WorkflowJobConclusion for WorkflowJob - JobStepStatus (3-value) for JobStep.status (JobStep.conclusion has no declared enum, kept str | None) - CheckRunStatus / CheckRunConclusion for CheckRun WorkflowRun.status/conclusion and GitHubUser.type declare no enum in the description, so they stay free-form strings. Add WorkflowRun.is_completed helper, retype update_check_run's conclusion param, and cover the new field types in the async client unit tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: b5088da | Docs | Datadog PR Page | Give us feedback! |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…enum-models # Conflicts: # ddev/tests/utils/test_github_async.py
…into hs/github-async-strenum-models
Contributor
Validation ReportAll 21 validations passed. Show details
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Models the GitHub REST API's declared-enum response fields as
StrEnums in the async client (ddev/src/ddev/utils/github_async/), following the folder's guidelines. Every decision is validated against GitHub's official OpenAPI description pinned toGITHUB_API_VERSION(2022-11-28).PullRequestState(open,closed) and retypesPullRequest.state.WorkflowJobStatus(6 values) andWorkflowJobConclusion(7 values, nullable) forWorkflowJob.JobStepStatus(3 values) forJobStep.status;JobStep.conclusionhas no declared enum, so it staysstr | None.CheckRunStatus(6 values) andCheckRunConclusion(7 values, nullable) forCheckRun.WorkflowRun.status/conclusionandGitHubUser.typeas free-form strings (the OpenAPI schema declares noenumfor them).WorkflowRun.is_completedhelper and retypesupdate_check_run'sconclusionparameter toCheckRunConclusion | None.docs.github.comreference backing each enum decision in the model docstrings and updates the async client unit tests.Motivation
Keeping workflow/job
status/conclusionand PRstateas bare strings does not scale: call sites compare against scattered string literals with no validation and no single source of truth. Modeling the declared-enum fields asStrEnums makes the allowed values explicit, validated, and self-documenting before the gatherer work that depends on these types lands. See AI-6959.Review checklist (to be filled by reviewers)
qa/requiredif this PR needs QA validation, orqa/skip-qaif it does not. Exactly one of the two is required.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged