Skip to content

Commit

Permalink
🐛 fix pull request head label and user (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu committed Dec 21, 2023
1 parent 1a60204 commit 93c24c5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
32 changes: 32 additions & 0 deletions githubkit/rest/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions githubkit/rest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions githubkit/rest/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -137,6 +136,15 @@ output_dir = "githubkit/rest/"
{ type = "null" },
{ "$ref" = "#/components/schemas/repository" },
], "$ref" = "<unset>" }
# 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 = [
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 93c24c5

Please sign in to comment.