Skip to content

Commit

Permalink
Sync GitTree class with API spec (#3132)
Browse files Browse the repository at this point in the history
Adds the following attributes:
- truncated
  • Loading branch information
EnricoMi authored Jan 8, 2025
1 parent 58f26d8 commit a38cb5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions github/GitTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class GitTree(CompletableGithubObject):
def _initAttributes(self) -> None:
self._sha: Attribute[str] = NotSet
self._tree: Attribute[list[GitTreeElement]] = NotSet
self._truncated: Attribute[bool] = NotSet
self._url: Attribute[str] = NotSet

def __repr__(self) -> str:
Expand All @@ -86,6 +87,11 @@ def tree(self) -> list[GitTreeElement]:
self._completeIfNotSet(self._tree)
return self._tree.value

@property
def truncated(self) -> bool:
self._completeIfNotSet(self._truncated)
return self._truncated.value

@property
def url(self) -> str:
self._completeIfNotSet(self._url)
Expand All @@ -96,5 +102,7 @@ def _useAttributes(self, attributes: dict[str, Any]) -> None:
self._sha = self._makeStringAttribute(attributes["sha"])
if "tree" in attributes: # pragma no branch
self._tree = self._makeListOfClassesAttribute(github.GitTreeElement.GitTreeElement, attributes["tree"])
if "truncated" in attributes: # pragma no branch
self._truncated = self._makeBoolAttribute(attributes["truncated"])
if "url" in attributes: # pragma no branch
self._url = self._makeStringAttribute(attributes["url"])
3 changes: 3 additions & 0 deletions tests/GitTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
# #
################################################################################

from __future__ import annotations

from . import Framework


Expand Down Expand Up @@ -62,6 +64,7 @@ def testAttributes(self):
self.tree.tree[6].url,
"https://api.github.com/repos/jacquev6/PyGithub/git/trees/60b4602b2c2070246c5df078fb7a5150b45815eb",
)
self.assertIsNone(self.tree.truncated)
self.assertEqual(
self.tree.url,
"https://api.github.com/repos/jacquev6/PyGithub/git/trees/f492784d8ca837779650d1fb406a1a3587a764ad",
Expand Down

0 comments on commit a38cb5a

Please sign in to comment.