/ github / PullRequestMergeStatus.py
PullRequestMergeStatus.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
 4  # Copyright 2012 Zearin <zearin@gonk.net>                                      #
 5  # Copyright 2013 AKFish <akfish@gmail.com>                                     #
 6  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
 7  # Copyright 2013 martinqt <m.ki2@laposte.net>                                  #
 8  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 9  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
10  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
11  # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
12  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
13  #                                                                              #
14  # This file is part of PyGithub.                                               #
15  # http://pygithub.readthedocs.io/                                              #
16  #                                                                              #
17  # PyGithub is free software: you can redistribute it and/or modify it under    #
18  # the terms of the GNU Lesser General Public License as published by the Free  #
19  # Software Foundation, either version 3 of the License, or (at your option)    #
20  # any later version.                                                           #
21  #                                                                              #
22  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
23  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
24  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
25  # details.                                                                     #
26  #                                                                              #
27  # You should have received a copy of the GNU Lesser General Public License     #
28  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
29  #                                                                              #
30  ################################################################################
31  from typing import Any, Dict
32  
33  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
34  
35  
36  class PullRequestMergeStatus(NonCompletableGithubObject):
37      """
38      This class represents PullRequestMergeStatuses. The reference can be found here https://docs.github.com/en/rest/reference/pulls#check-if-a-pull-request-has-been-merged
39      """
40  
41      def _initAttributes(self) -> None:
42          self._merged: Attribute[bool] = NotSet
43          self._message: Attribute[str] = NotSet
44          self._sha: Attribute[str] = NotSet
45  
46      def __repr__(self) -> str:
47          return self.get__repr__({"sha": self._sha.value, "merged": self._merged.value})
48  
49      @property
50      def merged(self) -> bool:
51          return self._merged.value
52  
53      @property
54      def message(self) -> str:
55          return self._message.value
56  
57      @property
58      def sha(self) -> str:
59          return self._sha.value
60  
61      def _useAttributes(self, attributes: Dict[str, Any]) -> None:
62          if "merged" in attributes:  # pragma no branch
63              self._merged = self._makeBoolAttribute(attributes["merged"])
64          if "message" in attributes:  # pragma no branch
65              self._message = self._makeStringAttribute(attributes["message"])
66          if "sha" in attributes:  # pragma no branch
67              self._sha = self._makeStringAttribute(attributes["sha"])