Skip to content

Commit

Permalink
Make Commit.files return PaginatedList
Browse files Browse the repository at this point in the history
  • Loading branch information
iarspider committed Apr 5, 2024
1 parent 7266e81 commit 7974fbd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
15 changes: 12 additions & 3 deletions github/Commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,18 @@ def committer(self) -> NamedUser:
return self._committer.value

@property
def files(self) -> list[File]:
self._completeIfNotSet(self._files)
return self._files.value
def files(self) -> PaginatedList[File]:
return PaginatedList(
github.File.File,
self._requester,
self.url,
{},
None,
"files",
"",
self.raw_data,
self.raw_headers,
)

@property
def html_url(self) -> str:
Expand Down
9 changes: 0 additions & 9 deletions tests/BadAttributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,6 @@ def testBadAttributeInClassAttribute(self):
owner.avatar_url
self.assertEqual(raisedexp.exception.actual_value, 42)

def testBadTransformedAttributeInList(self):
commit = self.g.get_repo("klmitch/turnstile", lazy=True).get_commit("38d9082a898d0822b5ccdfd78f3a536e2efa6c26")

with self.assertRaises(github.BadAttributeException) as raisedexp:
commit.files
self.assertEqual(raisedexp.exception.actual_value, [42])
self.assertEqual(raisedexp.exception.expected_type, [dict])
self.assertEqual(raisedexp.exception.transformation_exception, None)

def testBadTransformedAttributeInDict(self):
gist = self.g.get_gist("6437766")

Expand Down
2 changes: 1 addition & 1 deletion tests/Commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def testAttributes(self):
"https://api.github.com/repos/jacquev6/PyGithub/git/commits/1292bf0e22c796e91cc3d6e24b544aece8c21f2a",
)
self.assertEqual(self.commit.committer.login, "jacquev6")
self.assertEqual(len(self.commit.files), 1)
self.assertEqual(self.commit.files.totalCount, 1)
self.assertEqual(self.commit.files[0].additions, 0)
self.assertEqual(
self.commit.files[0].blob_url,
Expand Down

This file was deleted.

0 comments on commit 7974fbd

Please sign in to comment.