PullRequestPart.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 2014 Vincent Jacques <vincent@vincent-jacques.net> # 8 # Copyright 2016 Jannis Gebauer <ja.geb@me.com> # 9 # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> # 10 # Copyright 2018 Wan Liuyang <tsfdye@gmail.com> # 11 # Copyright 2018 sfdye <tsfdye@gmail.com> # 12 # # 13 # This file is part of PyGithub. # 14 # http://pygithub.readthedocs.io/ # 15 # # 16 # PyGithub is free software: you can redistribute it and/or modify it under # 17 # the terms of the GNU Lesser General Public License as published by the Free # 18 # Software Foundation, either version 3 of the License, or (at your option) # 19 # any later version. # 20 # # 21 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 23 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 24 # details. # 25 # # 26 # You should have received a copy of the GNU Lesser General Public License # 27 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 28 # # 29 ################################################################################ 30 from __future__ import annotations 31 32 from typing import TYPE_CHECKING, Any 33 34 import github.NamedUser 35 import github.Repository 36 from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet 37 38 if TYPE_CHECKING: 39 from github.NamedUser import NamedUser 40 from github.Repository import Repository 41 42 43 class PullRequestPart(NonCompletableGithubObject): 44 """ 45 This class represents PullRequestParts 46 """ 47 48 def _initAttributes(self) -> None: 49 self._label: Attribute[str] = NotSet 50 self._ref: Attribute[str] = NotSet 51 self._repo: Attribute[Repository] = NotSet 52 self._sha: Attribute[str] = NotSet 53 self._user: Attribute[NamedUser] = NotSet 54 55 def __repr__(self) -> str: 56 return self.get__repr__({"sha": self._sha.value}) 57 58 @property 59 def label(self) -> str: 60 return self._label.value 61 62 @property 63 def ref(self) -> str: 64 return self._ref.value 65 66 @property 67 def repo(self) -> Repository: 68 return self._repo.value 69 70 @property 71 def sha(self) -> str: 72 return self._sha.value 73 74 @property 75 def user(self) -> NamedUser: 76 return self._user.value 77 78 def _useAttributes(self, attributes: dict[str, Any]) -> None: 79 if "label" in attributes: # pragma no branch 80 self._label = self._makeStringAttribute(attributes["label"]) 81 if "ref" in attributes: # pragma no branch 82 self._ref = self._makeStringAttribute(attributes["ref"]) 83 if "repo" in attributes: # pragma no branch 84 self._repo = self._makeClassAttribute(github.Repository.Repository, attributes["repo"]) 85 if "sha" in attributes: # pragma no branch 86 self._sha = self._makeStringAttribute(attributes["sha"]) 87 if "user" in attributes: # pragma no branch 88 self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"])