From ab8134d08aca2bf50b690df2b0a18d4da7cc6e55 Mon Sep 17 00:00:00 2001 From: tison Date: Thu, 3 Nov 2022 23:02:10 +0800 Subject: [PATCH 1/3] Speed up get requested reviewers and teams for pr --- github/PullRequest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/github/PullRequest.py b/github/PullRequest.py index 47d16721b5..c0b706643b 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -48,6 +48,7 @@ import github.GithubObject import github.IssueComment import github.NamedUser +import github.Team import github.PaginatedList import github.PullRequestComment import github.PullRequestMergeStatus @@ -355,6 +356,17 @@ def updated_at(self): self._completeIfNotSet(self._updated_at) return self._updated_at.value + @property + def requested_reviewers(self): + self._completeIfNotSet(self._requested_reviewers) + return self._requested_reviewers.value + + @property + def requested_teams(self): + self._completeIfNotSet(self._requested_teams) + return self._requested_teams.value + + @property def url(self): """ @@ -984,6 +996,8 @@ def _initAttributes(self): self._updated_at = github.GithubObject.NotSet self._url = github.GithubObject.NotSet self._user = github.GithubObject.NotSet + self._requested_reviewers = github.GithubObject.NotSet + self._requested_teams = github.GithubObject.NotSet def _useAttributes(self, attributes): if "additions" in attributes: # pragma no branch @@ -1101,3 +1115,11 @@ def _useAttributes(self, attributes): self._user = self._makeClassAttribute( github.NamedUser.NamedUser, attributes["user"] ) + if "requested_reviewers" in attributes: + self._requested_reviewers = self._makeListOfClassesAttribute( + github.NamedUser.NamedUser, attributes["requested_reviewers"] + ) + if "requested_teams" in attributes: + self._requested_teams = self._makeListOfClassesAttribute( + github.Team.Team, attributes["requested_teams"] + ) From b1012be4744874fc66872166cd810c944b52c399 Mon Sep 17 00:00:00 2001 From: tison Date: Thu, 3 Nov 2022 23:03:03 +0800 Subject: [PATCH 2/3] Update PullRequest.pyi --- github/PullRequest.pyi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/github/PullRequest.pyi b/github/PullRequest.pyi index 597a85ad4a..7d37334786 100644 --- a/github/PullRequest.pyi +++ b/github/PullRequest.pyi @@ -30,6 +30,10 @@ class PullRequest(CompletableGithubObject): @property def assignees(self) -> List[NamedUser]: ... @property + def requested_reviewers(self) -> List[NamedUser]: ... + @property + def requested_teams(self) -> List[Team]: ... + @property def base(self) -> PullRequestPart: ... @property def body(self) -> str: ... From afd06efa14113daa664ebb8eba6bbc845f19b084 Mon Sep 17 00:00:00 2001 From: tison Date: Thu, 3 Nov 2022 23:07:43 +0800 Subject: [PATCH 3/3] make linter happy --- github/PullRequest.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/github/PullRequest.py b/github/PullRequest.py index c0b706643b..a7e9bb7f49 100644 --- a/github/PullRequest.py +++ b/github/PullRequest.py @@ -48,12 +48,12 @@ import github.GithubObject import github.IssueComment import github.NamedUser -import github.Team import github.PaginatedList import github.PullRequestComment import github.PullRequestMergeStatus import github.PullRequestPart import github.PullRequestReview +import github.Team from . import Consts @@ -363,9 +363,8 @@ def requested_reviewers(self): @property def requested_teams(self): - self._completeIfNotSet(self._requested_teams) - return self._requested_teams.value - + self._completeIfNotSet(self._requested_teams) + return self._requested_teams.value @property def url(self):