Skip to content

Commit

Permalink
update CloseEvent.reason
Browse files Browse the repository at this point in the history
  • Loading branch information
ShineyDev committed Jan 27, 2025
1 parent eb01f29 commit 99caa90
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions github/timeline/closeevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CloseEvent(Node, Resource, TimelineItem, Type):
_data: CloseEventData

_graphql_fields = {
"reason": "stateReason",
"reason": "closable{__typename},stateReason",
}

_node_prefix = "CE"
Expand All @@ -60,24 +60,37 @@ class CloseEvent(Node, Resource, TimelineItem, Type):
def reason(
self,
/,
) -> IssueCloseReason:
) -> IssueCloseReason | None:
"""
The reason the subject was closed.
:type: :class:`~github.IssueCloseReason`
.. note::
This is always None for pull requests, since the reason is
not provided by the API.
:type: :class:`~github.IssueCloseReason` | None
"""

if self._data["closable"]["__typename"] == "PullRequest":
return None

return github.IssueCloseReason(self._data["stateReason"])

async def fetch_reason(
self,
/,
) -> IssueCloseReason:
) -> IssueCloseReason | None:
"""
|coro|
Fetches the reason the subject was closed.
.. note::
This is always None for pull requests, since the reason is
not provided by the API.
Raises
------
Expand All @@ -86,10 +99,10 @@ async def fetch_reason(
The :attr:`id` attribute is missing.
:rtype: :class:`~github.IssueCloseReason`
:rtype: :class:`~github.IssueCloseReason` | None
"""

return github.IssueCloseReason(await self._fetch_field("stateReason"))
raise NotImplementedError # TODO

async def fetch_subject(
self,
Expand Down

0 comments on commit 99caa90

Please sign in to comment.