/ github / TimelineEventSource.py
TimelineEventSource.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2019 Nick Campbell <nicholas.j.campbell@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.Issue
28  from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
29  
30  if TYPE_CHECKING:
31      from github.Issue import Issue
32  
33  
34  class TimelineEventSource(NonCompletableGithubObject):
35      """
36      This class represents IssueTimelineEventSource. The reference can be found here https://docs.github.com/en/rest/reference/issues#timeline
37      """
38  
39      def _initAttributes(self) -> None:
40          self._type: Attribute[str] = NotSet
41          self._issue: Attribute[Issue] = NotSet
42  
43      def __repr__(self) -> str:
44          return self.get__repr__({"type": self._type.value})
45  
46      @property
47      def type(self) -> str:
48          return self._type.value
49  
50      @property
51      def issue(self) -> Issue:
52          return self._issue.value
53  
54      def _useAttributes(self, attributes: dict[str, Any]) -> None:
55          if "type" in attributes:  # pragma no branch
56              self._type = self._makeStringAttribute(attributes["type"])
57          if "issue" in attributes:  # pragma no branch
58              self._issue = self._makeClassAttribute(github.Issue.Issue, attributes["issue"])