Skip to content

Commit

Permalink
Sync IssuePullRequest class with API spec (#3143)
Browse files Browse the repository at this point in the history
Adds the following attributes:
- merged_at
- url
  • Loading branch information
EnricoMi authored Jan 9, 2025
1 parent be44bb5 commit 1836b07
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 19 additions & 2 deletions github/IssuePullRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
################################################################################


from typing import Any, Dict
from __future__ import annotations

from datetime import datetime
from typing import Any

from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet

Expand All @@ -54,7 +57,9 @@ class IssuePullRequest(NonCompletableGithubObject):
def _initAttributes(self) -> None:
self._diff_url: Attribute[str] = NotSet
self._html_url: Attribute[str] = NotSet
self._merged_at: Attribute[datetime] = NotSet
self._patch_url: Attribute[str] = NotSet
self._url: Attribute[str] = NotSet

@property
def diff_url(self) -> str:
Expand All @@ -64,14 +69,26 @@ def diff_url(self) -> str:
def html_url(self) -> str:
return self._html_url.value

@property
def merged_at(self) -> datetime:
return self._merged_at.value

@property
def patch_url(self) -> str:
return self._patch_url.value

def _useAttributes(self, attributes: Dict[str, Any]) -> None:
@property
def url(self) -> str:
return self._url.value

def _useAttributes(self, attributes: dict[str, Any]) -> None:
if "diff_url" in attributes: # pragma no branch
self._diff_url = self._makeStringAttribute(attributes["diff_url"])
if "html_url" in attributes: # pragma no branch
self._html_url = self._makeStringAttribute(attributes["html_url"])
if "merged_at" in attributes: # pragma no branch
self._merged_at = self._makeDatetimeAttribute(attributes["merged_at"])
if "patch_url" in attributes: # pragma no branch
self._patch_url = self._makeStringAttribute(attributes["patch_url"])
if "url" in attributes: # pragma no branch
self._url = self._makeStringAttribute(attributes["url"])
2 changes: 2 additions & 0 deletions tests/Issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def testAttributes(self):
self.assertEqual(self.issue.number, 28)
self.assertEqual(self.issue.pull_request.diff_url, None)
self.assertEqual(self.issue.pull_request.patch_url, None)
self.assertEqual(self.issue.pull_request.merged_at, None)
self.assertEqual(self.issue.pull_request.html_url, None)
self.assertEqual(self.issue.pull_request.url, None)
self.assertEqual(self.issue.state, "closed")
self.assertEqual(self.issue.state_reason, "completed")
self.assertEqual(self.issue.title, "Issue created by PyGithub")
Expand Down

0 comments on commit 1836b07

Please sign in to comment.