Skip to content

Commit

Permalink
implement LabelRemoveEvent.fetch_label (UnlabeledEvent.label) field
Browse files Browse the repository at this point in the history
  • Loading branch information
ShineyDev committed Jan 30, 2025
1 parent 31a1f52 commit 8b2aa0b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
18 changes: 18 additions & 0 deletions github/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,24 @@ async def fetch_labeladdevent_subject(

return data

async def fetch_labelremoveevent_label(
self,
/,
labelremoveevent_id: str,
*,
fields: Iterable[str] = MISSING,
) -> LabelData:
fields = github.utility.get_merged_graphql_fields(github.Label, fields)
query = "query($labelremoveevent_id:ID!){node(id:$labelremoveevent_id){...on UnlabeledEvent{label{%s}}}}" % ",".join(fields)
path = ("node", "label")

data = await self._fetch(query, *path, labelremoveevent_id=labelremoveevent_id)

if TYPE_CHECKING:
data = cast(LabelData, data)

return data

async def fetch_labelremoveevent_subject(
self,
/,
Expand Down
26 changes: 25 additions & 1 deletion github/timeline/labelremoveevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from github.repository import Issue, Pull
from github.repository import Issue, Label, Pull

import github
from github.interfaces import Node, TimelineItem, Type
Expand Down Expand Up @@ -52,6 +52,30 @@ class LabelRemoveEvent(Node, TimelineItem, Type):

_node_prefix = "UNLE"

async def fetch_label(
self,
/,
**kwargs, # TODO
) -> Label:
"""
|coro|
Fetches the label removed.
Raises
------
~github.core.errors.ClientObjectMissingFieldError
The :attr:`id` attribute is missing.
:rtype: :class:`~github.Label`
"""

data = await self._http.fetch_labelremoveevent_label(self.id, **kwargs)
return github.Label._from_data(data, http=self._http)

async def fetch_subject(
self,
/,
Expand Down

0 comments on commit 8b2aa0b

Please sign in to comment.