Merge Event type stub back to source (#2660)

This commit is contained in:
Trim21
2023-08-30 09:17:20 +02:00
committed by GitHub
parent 356022d1d5
commit a04c1c2a5a
3 changed files with 28 additions and 75 deletions
+24 -45
View File
@@ -27,90 +27,69 @@
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
# #
################################################################################
from __future__ import annotations
from typing import Any, Dict
from datetime import datetime
from typing import Any
import github.GithubObject
import github.NamedUser
import github.Organization
import github.Repository
from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
class Event(github.GithubObject.NonCompletableGithubObject):
class Event(NonCompletableGithubObject):
"""
This class represents Events. The reference can be found here https://docs.github.com/en/rest/reference/activity#events
"""
def _initAttributes(self) -> None:
self._actor: Attribute[github.NamedUser.NamedUser] = NotSet
self._created_at: Attribute[datetime] = NotSet
self._id: Attribute[str] = NotSet
self._org: Attribute[github.Organization.Organization] = NotSet
self._payload: Attribute[dict[str, Any]] = NotSet
self._public: Attribute[bool] = NotSet
self._repo: Attribute[github.Repository.Repository] = NotSet
self._type: Attribute[str] = NotSet
def __repr__(self) -> str:
return self.get__repr__({"id": self._id.value, "type": self._type.value})
@property
def actor(self):
"""
:type: :class:`github.NamedUser.NamedUser`
"""
def actor(self) -> github.NamedUser.NamedUser:
return self._actor.value
@property
def created_at(self):
"""
:type: datetime.datetime
"""
def created_at(self) -> datetime:
return self._created_at.value
@property
def id(self):
"""
:type: string
"""
def id(self) -> str:
return self._id.value
@property
def org(self):
"""
:type: :class:`github.Organization.Organization`
"""
def org(self) -> github.Organization.Organization:
return self._org.value
@property
def payload(self):
"""
:type: dict
"""
def payload(self) -> dict[str, Any]:
return self._payload.value
@property
def public(self):
"""
:type: bool
"""
def public(self) -> bool:
return self._public.value
@property
def repo(self):
"""
:type: :class:`github.Repository.Repository`
"""
def repo(self) -> github.Repository.Repository:
return self._repo.value
@property
def type(self):
"""
:type: string
"""
def type(self) -> str:
return self._type.value
def _initAttributes(self) -> None:
self._actor = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._org = github.GithubObject.NotSet
self._payload = github.GithubObject.NotSet
self._public = github.GithubObject.NotSet
self._repo = github.GithubObject.NotSet
self._type = github.GithubObject.NotSet
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
def _useAttributes(self, attributes: dict[str, Any]) -> None:
if "actor" in attributes: # pragma no branch
self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"])
if "created_at" in attributes: # pragma no branch
-28
View File
@@ -1,28 +0,0 @@
from datetime import datetime
from typing import Any, Dict
from github.GithubObject import NonCompletableGithubObject
from github.NamedUser import NamedUser
from github.Organization import Organization
from github.Repository import Repository
class Event(NonCompletableGithubObject):
def __repr__(self) -> str: ...
def _initAttributes(self) -> None: ...
def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
@property
def actor(self) -> NamedUser: ...
@property
def created_at(self) -> datetime: ...
@property
def id(self) -> str: ...
@property
def org(self) -> Organization: ...
@property
def payload(self) -> Dict[str, Any]: ...
@property
def public(self) -> bool: ...
@property
def repo(self) -> Repository: ...
@property
def type(self) -> str: ...
+4 -2
View File
@@ -19,8 +19,10 @@
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
# #
################################################################################
from __future__ import annotations
from datetime import datetime
from typing import Any, Dict
from typing import Any
from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet
@@ -90,7 +92,7 @@ class Topic(NonCompletableGithubObject):
def score(self) -> float:
return self._score.value
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
def _useAttributes(self, attributes: dict[str, Any]) -> None:
if "name" in attributes: # pragma no branch
self._name = self._makeStringAttribute(attributes["name"])
if "display_name" in attributes: # pragma no branch