Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A property to access the assets field of release (#1898) #1899

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions github/GitRelease.py
Expand Up @@ -170,6 +170,16 @@ def zipball_url(self):
self._completeIfNotSet(self._zipball_url)
return self._zipball_url.value

@property
def assets(self):
"""
Already returned assets info (no additional requests will be done).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the :type: here, please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where to put a note on the difference between get_assets() and assets though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Hmm...

Just the :type: here, please

How then it should be mentioned which methods do additional requests and which not?
Sorry to remind but GitHub has limits...


:type: list of :class:`github.GitReleaseAsset.GitReleaseAsset`
"""
self._completeIfNotSet(self._assets)
return self._assets.value

def delete_release(self):
"""
:calls: `DELETE /repos/{owner}/{repo}/releases/{release_id} <https://docs.github.com/en/rest/reference/repos/releases#delete-a-release>`_
Expand Down Expand Up @@ -333,6 +343,7 @@ def _initAttributes(self):
self._published_at = github.GithubObject.NotSet
self._tarball_url = github.GithubObject.NotSet
self._zipball_url = github.GithubObject.NotSet
self._assets = github.GithubObject.NotSet

def _useAttributes(self, attributes):
if "id" in attributes:
Expand Down Expand Up @@ -369,3 +380,7 @@ def _useAttributes(self, attributes):
self._tarball_url = self._makeStringAttribute(attributes["tarball_url"])
if "zipball_url" in attributes:
self._zipball_url = self._makeStringAttribute(attributes["zipball_url"])
if "assets" in attributes:
self._assets = self._makeListOfClassesAttribute(
github.GitReleaseAsset.GitReleaseAsset, attributes["assets"]
)
2 changes: 2 additions & 0 deletions github/GitRelease.pyi
Expand Up @@ -11,6 +11,8 @@ class GitRelease(CompletableGithubObject):
def _initAttributes(self) -> None: ...
def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
@property
def assets(self) -> list[GitReleaseAsset]: ...
@property
def author(self) -> NamedUser: ...
@property
def body(self) -> str: ...
Expand Down