From 93c24c5856d1103be179f749e23dd89b125c21e8 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:28:57 +0800 Subject: [PATCH] :bug: fix pull request head label and user (#72) --- githubkit/rest/activity.py | 32 ++++++++++++++++++++++++++++++++ githubkit/rest/models.py | 4 ++-- githubkit/rest/types.py | 4 ++-- pyproject.toml | 19 +++++++++++++++++-- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/githubkit/rest/activity.py b/githubkit/rest/activity.py index 4a03a128..985673b5 100644 --- a/githubkit/rest/activity.py +++ b/githubkit/rest/activity.py @@ -418,6 +418,38 @@ async def async_get_thread( }, ) + def mark_thread_as_done( + self, + thread_id: int, + *, + headers: Optional[Dict[str, str]] = None, + ) -> "Response": + url = f"/notifications/threads/{thread_id}" + + headers = {"X-GitHub-Api-Version": self._REST_API_VERSION, **(headers or {})} + + return self._github.request( + "DELETE", + url, + headers=exclude_unset(headers), + ) + + async def async_mark_thread_as_done( + self, + thread_id: int, + *, + headers: Optional[Dict[str, str]] = None, + ) -> "Response": + url = f"/notifications/threads/{thread_id}" + + headers = {"X-GitHub-Api-Version": self._REST_API_VERSION, **(headers or {})} + + return await self._github.arequest( + "DELETE", + url, + headers=exclude_unset(headers), + ) + def mark_thread_as_read( self, thread_id: int, diff --git a/githubkit/rest/models.py b/githubkit/rest/models.py index 462a404e..b9a3dfef 100644 --- a/githubkit/rest/models.py +++ b/githubkit/rest/models.py @@ -11221,11 +11221,11 @@ class PullRequestPropLabelsItems(GitHubRestModel): class PullRequestPropHead(GitHubRestModel): """PullRequestPropHead""" - label: str = Field(default=...) + label: Union[str, None] = Field(default=...) ref: str = Field(default=...) repo: Union[PullRequestPropHeadPropRepo, None] = Field(default=...) sha: str = Field(default=...) - user: PullRequestPropHeadPropUser = Field(default=...) + user: Union[PullRequestPropHeadPropUser, None] = Field(default=...) class PullRequestPropHeadPropRepoPropOwner(GitHubRestModel): diff --git a/githubkit/rest/types.py b/githubkit/rest/types.py index c89ac5f2..81b16683 100644 --- a/githubkit/rest/types.py +++ b/githubkit/rest/types.py @@ -8008,11 +8008,11 @@ class PullRequestPropLabelsItemsType(TypedDict): class PullRequestPropHeadType(TypedDict): """PullRequestPropHead""" - label: str + label: Union[str, None] ref: str repo: Union[PullRequestPropHeadPropRepoType, None] sha: str - user: PullRequestPropHeadPropUserType + user: Union[PullRequestPropHeadPropUserType, None] class PullRequestPropHeadPropRepoPropOwnerType(TypedDict): diff --git a/pyproject.toml b/pyproject.toml index b16ebdaf..31924884 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -127,7 +127,6 @@ output_dir = "githubkit/rest/" # https://github.com/github/rest-api-description/issues/1811 -# https://github.com/yanyongyu/githubkit/issues/56 # https://github.com/yanyongyu/githubkit/issues/64 "/components/schemas/pull-request-simple/properties/head/properties/label" = { type = [ "string", @@ -137,6 +136,15 @@ output_dir = "githubkit/rest/" { type = "null" }, { "$ref" = "#/components/schemas/repository" }, ], "$ref" = "" } +# https://github.com/yanyongyu/githubkit/issues/56 +"/components/schemas/pull-request/properties/head/properties/label" = { type = [ + "string", + "null", +] } +"/components/schemas/pull-request/properties/head/properties/user" = { type = [ + "object", + "null", +] } # https://github.com/github/rest-api-description/issues/1812 "/components/schemas/pull-request-simple/properties/labels/items/properties/description" = { type = [ @@ -265,7 +273,14 @@ types_output = "githubkit/webhooks/types.py" # "/definitions/secret_scanning_alert$resolved/properties/alert/allOf/1/properties/resolution" = { enum = ["false_positive", "wont_fix", "revoked", "used_in_tests"] } # https://github.com/yanyongyu/githubkit/pull/69 -"/definitions/projects_v2_item$edited/properties/changes/properties/field_value/properties/field_type" = { enum = [ "single_select", "date", "number", "text", "iteration", "labels" ] } +"/definitions/projects_v2_item$edited/properties/changes/properties/field_value/properties/field_type" = { enum = [ + "single_select", + "date", + "number", + "text", + "iteration", + "labels", +] } [tool.codegen.field_overrides] "+1" = "plus_one"