RequiredStatusChecks.py
1 ############################ Copyrights and license ############################ 2 # # 3 # Copyright 2018 Steve Kowalik <steven@wedontsleep.org> # 4 # # 5 # This file is part of PyGithub. # 6 # http://pygithub.readthedocs.io/ # 7 # # 8 # PyGithub is free software: you can redistribute it and/or modify it under # 9 # the terms of the GNU Lesser General Public License as published by the Free # 10 # Software Foundation, either version 3 of the License, or (at your option) # 11 # any later version. # 12 # # 13 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 15 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 16 # details. # 17 # # 18 # You should have received a copy of the GNU Lesser General Public License # 19 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 20 # # 21 ################################################################################ 22 from __future__ import annotations 23 24 from typing import Any 25 26 from github.GithubObject import Attribute, CompletableGithubObject, NotSet 27 28 29 class RequiredStatusChecks(CompletableGithubObject): 30 """ 31 This class represents Required Status Checks. The reference can be found here https://docs.github.com/en/rest/reference/repos#get-status-checks-protection 32 """ 33 34 def _initAttributes(self) -> None: 35 self._strict: Attribute[bool] = NotSet 36 self._contexts: Attribute[list[str]] = NotSet 37 self._url: Attribute[str] = NotSet 38 39 def __repr__(self) -> str: 40 return self.get__repr__({"strict": self._strict.value, "url": self._url.value}) 41 42 @property 43 def strict(self) -> bool: 44 self._completeIfNotSet(self._strict) 45 return self._strict.value 46 47 @property 48 def contexts(self) -> list[str]: 49 self._completeIfNotSet(self._contexts) 50 return self._contexts.value 51 52 @property 53 def url(self) -> str: 54 self._completeIfNotSet(self._url) 55 return self._url.value 56 57 def _useAttributes(self, attributes: dict[str, Any]) -> None: 58 if "strict" in attributes: # pragma no branch 59 self._strict = self._makeBoolAttribute(attributes["strict"]) 60 if "contexts" in attributes: # pragma no branch 61 self._contexts = self._makeListOfStringsAttribute(attributes["contexts"]) 62 if "url" in attributes: # pragma no branch 63 self._url = self._makeStringAttribute(attributes["url"])