/ github / RepositoryPreferences.py
RepositoryPreferences.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2020 Dhruv Manilawala <dhruvmanila@gmail.com>                      #
 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  
23  from __future__ import annotations
24  
25  from typing import TYPE_CHECKING, Any
26  
27  import github.Repository
28  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
29  
30  if TYPE_CHECKING:
31      from github.Repository import Repository
32  
33  
34  class RepositoryPreferences(NonCompletableGithubObject):
35      """
36      This class represents repository preferences.
37      The reference can be found here https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#update-repository-preferences-for-check-suites
38      """
39  
40      def _initAttributes(self) -> None:
41          self._preferences: Attribute[dict[str, list[dict[str, bool | int]]]] = NotSet
42          self._repository: Attribute[Repository] = NotSet
43  
44      @property
45      def preferences(self) -> dict[str, list[dict[str, bool | int]]]:
46          return self._preferences.value
47  
48      @property
49      def repository(self) -> Repository:
50          return self._repository.value
51  
52      def _useAttributes(self, attributes: dict[str, Any]) -> None:
53          if "preferences" in attributes:  # pragma no branch
54              self._preferences = self._makeDictAttribute(attributes["preferences"])
55          if "repository" in attributes:  # pragma no branch
56              self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"])