From 9989b112f754c54c8d756ea5364e9bff5a231c29 Mon Sep 17 00:00:00 2001 From: Trim21 Date: Tue, 18 Jul 2023 22:47:52 +0800 Subject: [PATCH] Merge type stub bask to source: `Comparison` `CommitStatus` `CommitCombinedStatus` (#2633) Co-authored-by: Enrico Minack --- github/CommitCombinedStatus.py | 62 +++++++----------- github/CommitCombinedStatus.pyi | 24 ------- github/CommitStatus.py | 76 ++++++++--------------- github/CommitStatus.pyi | 28 --------- github/Comparison.py | 107 +++++++++++--------------------- github/Comparison.pyi | 35 ----------- 6 files changed, 83 insertions(+), 249 deletions(-) delete mode 100644 github/CommitCombinedStatus.pyi delete mode 100644 github/CommitStatus.pyi delete mode 100644 github/Comparison.pyi diff --git a/github/CommitCombinedStatus.py b/github/CommitCombinedStatus.py index 058021cc..d9bfdb30 100644 --- a/github/CommitCombinedStatus.py +++ b/github/CommitCombinedStatus.py @@ -23,81 +23,61 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations -from typing import Any, Dict +from typing import Any import github.CommitStatus -import github.GithubObject import github.Repository +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class CommitCombinedStatus(github.GithubObject.NonCompletableGithubObject): +class CommitCombinedStatus(NonCompletableGithubObject): """ This class represents CommitCombinedStatuses. The reference can be found here https://docs.github.com/en/rest/reference/repos#statuses """ + def _initAttributes(self) -> None: + self._state: Attribute[str] = NotSet + self._sha: Attribute[str] = NotSet + self._total_count: Attribute[int] = NotSet + self._commit_url: Attribute[str] = NotSet + self._url: Attribute[str] = NotSet + self._repository: Attribute[github.Repository.Repository] = NotSet + self._statuses: Attribute[list[github.CommitStatus.CommitStatus]] = NotSet + def __repr__(self) -> str: return self.get__repr__({"sha": self._sha.value, "state": self._state.value}) @property - def state(self): - """ - :type: string - """ + def state(self) -> str: return self._state.value @property - def sha(self): - """ - :type: string - """ + def sha(self) -> str: return self._sha.value @property - def total_count(self): - """ - :type: integer - """ + def total_count(self) -> int: return self._total_count.value @property - def commit_url(self): - """ - :type: string - """ + def commit_url(self) -> str: return self._commit_url.value @property - def url(self): - """ - :type: string - """ + def url(self) -> str: return self._url.value @property - def repository(self): - """ - :type: :class:`github.Repository.Repository` - """ + def repository(self) -> github.Repository.Repository: return self._repository.value @property - def statuses(self): - """ - :type: list of :class:`CommitStatus` - """ + def statuses(self) -> list[github.CommitStatus.CommitStatus]: return self._statuses.value - def _initAttributes(self) -> None: - self._state = github.GithubObject.NotSet - self._sha = github.GithubObject.NotSet - self._total_count = github.GithubObject.NotSet - self._commit_url = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet - self._repository = github.GithubObject.NotSet - self._statuses = github.GithubObject.NotSet - - def _useAttributes(self, attributes: Dict[str, Any]) -> None: + def _useAttributes(self, attributes: dict[str, Any]) -> None: if "state" in attributes: # pragma no branch self._state = self._makeStringAttribute(attributes["state"]) if "sha" in attributes: # pragma no branch diff --git a/github/CommitCombinedStatus.pyi b/github/CommitCombinedStatus.pyi deleted file mode 100644 index 65818c8e..00000000 --- a/github/CommitCombinedStatus.pyi +++ /dev/null @@ -1,24 +0,0 @@ -from typing import Any, Dict, List - -from github.CommitStatus import CommitStatus -from github.GithubObject import NonCompletableGithubObject -from github.Repository import Repository - -class CommitCombinedStatus(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def commit_url(self) -> str: ... - @property - def repository(self) -> Repository: ... - @property - def sha(self) -> str: ... - @property - def state(self) -> str: ... - @property - def statuses(self) -> List[CommitStatus]: ... - @property - def total_count(self) -> int: ... - @property - def url(self) -> str: ... diff --git a/github/CommitStatus.py b/github/CommitStatus.py index a1def298..6e50ef6d 100644 --- a/github/CommitStatus.py +++ b/github/CommitStatus.py @@ -29,18 +29,32 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations -from typing import Any, Dict +from datetime import datetime +from typing import Any import github.GithubObject import github.NamedUser +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet -class CommitStatus(github.GithubObject.NonCompletableGithubObject): +class CommitStatus(NonCompletableGithubObject): """ This class represents CommitStatuses.The reference can be found here https://docs.github.com/en/rest/reference/repos#statuses """ + def _initAttributes(self) -> None: + self._created_at: Attribute[datetime] = NotSet + self._creator: Attribute[github.NamedUser.NamedUser] = NotSet + self._description: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._state: Attribute[str] = NotSet + self._context: Attribute[str] = NotSet + self._target_url: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + def __repr__(self) -> str: return self.get__repr__( { @@ -51,80 +65,42 @@ class CommitStatus(github.GithubObject.NonCompletableGithubObject): ) @property - def created_at(self): - """ - :type: datetime.datetime - """ + def created_at(self) -> datetime: return self._created_at.value @property - def creator(self): - """ - :type: :class:`github.NamedUser.NamedUser` - """ + def creator(self) -> github.NamedUser.NamedUser: return self._creator.value @property - def description(self): - """ - :type: string - """ + def description(self) -> str: return self._description.value @property - def id(self): - """ - :type: integer - """ + def id(self) -> int: return self._id.value @property - def state(self): - """ - :type: string - """ + def state(self) -> str: return self._state.value @property - def context(self): - """ - :type: string - """ + def context(self) -> str: return self._context.value @property - def target_url(self): - """ - :type: string - """ + def target_url(self) -> str: return self._target_url.value @property - def updated_at(self): - """ - :type: datetime.datetime - """ + def updated_at(self) -> datetime: return self._updated_at.value @property - def url(self): - """ - :type: string - """ + def url(self) -> str: return self._url.value - def _initAttributes(self) -> None: - self._created_at = github.GithubObject.NotSet - self._creator = github.GithubObject.NotSet - self._description = github.GithubObject.NotSet - self._id = github.GithubObject.NotSet - self._state = github.GithubObject.NotSet - self._context = github.GithubObject.NotSet - self._target_url = github.GithubObject.NotSet - self._updated_at = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet - - def _useAttributes(self, attributes: Dict[str, Any]) -> None: + def _useAttributes(self, attributes: dict[str, Any]) -> None: if "created_at" in attributes: # pragma no branch self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) if "creator" in attributes: # pragma no branch diff --git a/github/CommitStatus.pyi b/github/CommitStatus.pyi deleted file mode 100644 index 41f7c288..00000000 --- a/github/CommitStatus.pyi +++ /dev/null @@ -1,28 +0,0 @@ -from datetime import datetime -from typing import Any, Dict, Optional - -from github.GithubObject import NonCompletableGithubObject -from github.NamedUser import NamedUser - -class CommitStatus(NonCompletableGithubObject): - def __repr__(self) -> str: ... - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def context(self) -> str: ... - @property - def created_at(self) -> datetime: ... - @property - def creator(self) -> NamedUser: ... - @property - def description(self) -> Optional[str]: ... - @property - def id(self) -> int: ... - @property - def state(self) -> str: ... - @property - def target_url(self) -> Optional[str]: ... - @property - def updated_at(self) -> datetime: ... - @property - def url(self) -> str: ... diff --git a/github/Comparison.py b/github/Comparison.py index 01d6c188..f09e3ef2 100644 --- a/github/Comparison.py +++ b/github/Comparison.py @@ -26,139 +26,104 @@ # along with PyGithub. If not, see . # # # ################################################################################ +from __future__ import annotations -from typing import Any, Dict +from typing import Any import github.Commit import github.File -import github.GithubObject +from github.GithubObject import Attribute, CompletableGithubObject, NotSet -class Comparison(github.GithubObject.CompletableGithubObject): +class Comparison(CompletableGithubObject): """ This class represents Comparisons """ + def _initAttributes(self) -> None: + self._ahead_by: Attribute[int] = NotSet + self._base_commit: Attribute[github.Commit.Commit] = NotSet + self._behind_by: Attribute[int] = NotSet + self._commits: Attribute[list[github.Commit.Commit]] = NotSet + self._diff_url: Attribute[str] = NotSet + self._files: Attribute[list[github.File.File]] = NotSet + self._html_url: Attribute[str] = NotSet + self._merge_base_commit: Attribute[github.Commit.Commit] = NotSet + self._patch_url: Attribute[str] = NotSet + self._permalink_url: Attribute[str] = NotSet + self._status: Attribute[str] = NotSet + self._total_commits: Attribute[int] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"url": self._url.value}) + @property - def ahead_by(self): - """ - :type: integer - """ + def ahead_by(self) -> int: self._completeIfNotSet(self._ahead_by) return self._ahead_by.value @property - def base_commit(self): - """ - :type: :class:`github.Commit.Commit` - """ + def base_commit(self) -> github.Commit.Commit: self._completeIfNotSet(self._base_commit) return self._base_commit.value @property - def behind_by(self): - """ - :type: integer - """ + def behind_by(self) -> int: self._completeIfNotSet(self._behind_by) return self._behind_by.value @property - def commits(self): - """ - :type: list of :class:`github.Commit.Commit` - """ + def commits(self) -> list[github.Commit.Commit]: self._completeIfNotSet(self._commits) return self._commits.value @property - def diff_url(self): - """ - :type: string - """ + def diff_url(self) -> str: self._completeIfNotSet(self._diff_url) return self._diff_url.value @property - def files(self): - """ - :type: list of :class:`github.File.File` - """ + def files(self) -> list[github.File.File]: self._completeIfNotSet(self._files) return self._files.value @property - def html_url(self): - """ - :type: string - """ + def html_url(self) -> str: self._completeIfNotSet(self._html_url) return self._html_url.value @property - def merge_base_commit(self): - """ - :type: :class:`github.Commit.Commit` - """ + def merge_base_commit(self) -> github.Commit.Commit: self._completeIfNotSet(self._merge_base_commit) return self._merge_base_commit.value @property - def patch_url(self): - """ - :type: string - """ + def patch_url(self) -> str: self._completeIfNotSet(self._patch_url) return self._patch_url.value @property - def permalink_url(self): - """ - :type: string - """ + def permalink_url(self) -> str: self._completeIfNotSet(self._permalink_url) return self._permalink_url.value @property - def status(self): - """ - :type: string - """ + def status(self) -> str: self._completeIfNotSet(self._status) return self._status.value @property - def total_commits(self): - """ - :type: integer - """ + def total_commits(self) -> int: self._completeIfNotSet(self._total_commits) return self._total_commits.value @property - def url(self): - """ - :type: string - """ + def url(self) -> str: self._completeIfNotSet(self._url) return self._url.value - def _initAttributes(self) -> None: - self._ahead_by = github.GithubObject.NotSet - self._base_commit = github.GithubObject.NotSet - self._behind_by = github.GithubObject.NotSet - self._commits = github.GithubObject.NotSet - self._diff_url = github.GithubObject.NotSet - self._files = github.GithubObject.NotSet - self._html_url = github.GithubObject.NotSet - self._merge_base_commit = github.GithubObject.NotSet - self._patch_url = github.GithubObject.NotSet - self._permalink_url = github.GithubObject.NotSet - self._status = github.GithubObject.NotSet - self._total_commits = github.GithubObject.NotSet - self._url = github.GithubObject.NotSet - - def _useAttributes(self, attributes: Dict[str, Any]) -> None: + def _useAttributes(self, attributes: dict[str, Any]) -> None: if "ahead_by" in attributes: # pragma no branch self._ahead_by = self._makeIntAttribute(attributes["ahead_by"]) if "base_commit" in attributes: # pragma no branch diff --git a/github/Comparison.pyi b/github/Comparison.pyi deleted file mode 100644 index 03c8f831..00000000 --- a/github/Comparison.pyi +++ /dev/null @@ -1,35 +0,0 @@ -from typing import Any, Dict, List - -from github.Commit import Commit -from github.File import File -from github.GithubObject import CompletableGithubObject - -class Comparison(CompletableGithubObject): - def _initAttributes(self) -> None: ... - def _useAttributes(self, attributes: Dict[str, Any]) -> None: ... - @property - def ahead_by(self) -> int: ... - @property - def base_commit(self) -> Commit: ... - @property - def behind_by(self) -> int: ... - @property - def commits(self) -> List[Commit]: ... - @property - def diff_url(self) -> str: ... - @property - def files(self) -> List[File]: ... - @property - def html_url(self) -> str: ... - @property - def merge_base_commit(self) -> Commit: ... - @property - def patch_url(self) -> str: ... - @property - def permalink_url(self) -> str: ... - @property - def status(self) -> str: ... - @property - def total_commits(self) -> int: ... - @property - def url(self) -> str: ...