Merge CheckSuite type stub back to source (#2606)

Co-authored-by: Enrico Minack <github@enrico.minack.dev>
This commit is contained in:
Trim21
2023-07-18 14:44:54 +02:00
committed by GitHub
co-authored by Enrico Minack
parent cb92c7be53
commit 0779bf33c6
2 changed files with 67 additions and 104 deletions
+67 -55
View File
@@ -20,21 +20,55 @@
# #
################################################################################
from typing import Any, Dict
from __future__ import annotations
import github
from datetime import datetime
from typing import TYPE_CHECKING, Any
import github.CheckRun
import github.GitCommit
import github.GithubApp
import github.PullRequest
import github.Repository
from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt, is_defined, is_optional
from github.PaginatedList import PaginatedList
if TYPE_CHECKING:
from github.CheckRun import CheckRun
from github.GitCommit import GitCommit
from github.GithubApp import GithubApp
from github.PullRequest import PullRequest
from github.Repository import Repository
class CheckSuite(github.GithubObject.CompletableGithubObject):
class CheckSuite(CompletableGithubObject):
"""
This class represents check suites. The reference can be found here https://docs.github.com/en/rest/reference/checks#check-suites
"""
def _initAttributes(self) -> None:
self._after: Attribute[str] = NotSet
self._app: Attribute[GithubApp] = NotSet
self._before: Attribute[str] = NotSet
self._check_runs_url: Attribute[str] = NotSet
self._conclusion: Attribute[str] = NotSet
self._created_at: Attribute[datetime] = NotSet
self._head_branch: Attribute[str] = NotSet
self._head_commit: Attribute[GitCommit] = NotSet
self._head_sha: Attribute[str] = NotSet
self._id: Attribute[int] = NotSet
self._latest_check_runs_count: Attribute[int] = NotSet
self._pull_requests: Attribute[list[PullRequest]] = NotSet
self._repository: Attribute[Repository] = NotSet
self._status: Attribute[str] = NotSet
self._updated_at: Attribute[datetime] = NotSet
self._url: Attribute[str] = NotSet
def __repr__(self) -> str:
return self.get__repr__({"id": self._id.value, "url": self._url.value})
@property
def after(self):
def after(self) -> str:
"""
:type: string
"""
@@ -42,7 +76,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._after.value
@property
def app(self):
def app(self) -> GithubApp:
"""
:type: :class:`github.GithubApp.GithubApp`
"""
@@ -50,7 +84,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._app.value
@property
def before(self):
def before(self) -> str:
"""
:type: string
"""
@@ -58,7 +92,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._before.value
@property
def check_runs_url(self):
def check_runs_url(self) -> str:
"""
:type: string
"""
@@ -66,7 +100,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._check_runs_url.value
@property
def conclusion(self):
def conclusion(self) -> str:
"""
:type: string
"""
@@ -74,7 +108,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._conclusion.value
@property
def created_at(self):
def created_at(self) -> datetime:
"""
:type: datetime.datetime
"""
@@ -82,7 +116,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._created_at.value
@property
def head_branch(self):
def head_branch(self) -> str:
"""
:type: string
"""
@@ -90,7 +124,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._head_branch.value
@property
def head_commit(self):
def head_commit(self) -> GitCommit:
"""
:type: :class:`github.GitCommit.GitCommit`
"""
@@ -98,7 +132,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._head_commit.value
@property
def head_sha(self):
def head_sha(self) -> str:
"""
:type: string
"""
@@ -106,7 +140,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._head_sha.value
@property
def id(self):
def id(self) -> int:
"""
:type: int
"""
@@ -114,7 +148,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._id.value
@property
def latest_check_runs_count(self):
def latest_check_runs_count(self) -> int:
"""
:type: int
"""
@@ -122,7 +156,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._latest_check_runs_count.value
@property
def pull_requests(self):
def pull_requests(self) -> list[PullRequest]:
"""
:type: list of :class:`github.PullRequest.PullRequest`
"""
@@ -130,7 +164,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._pull_requests.value
@property
def repository(self):
def repository(self) -> Repository:
"""
:type: :class:`github.Repository.Repository`
"""
@@ -138,7 +172,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._repository.value
@property
def status(self):
def status(self) -> str:
"""
:type: string
"""
@@ -146,7 +180,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._status.value
@property
def updated_at(self):
def updated_at(self) -> datetime:
"""
:type: datetime.datetime
"""
@@ -154,14 +188,14 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
return self._updated_at.value
@property
def url(self):
def url(self) -> str:
"""
:type: string
"""
self._completeIfNotSet(self._url)
return self._url.value
def rerequest(self):
def rerequest(self) -> bool:
"""
:calls: `POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest <https://docs.github.com/en/rest/reference/checks#rerequest-a-check-suite>`_
:rtype: bool
@@ -172,28 +206,24 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
def get_check_runs(
self,
check_name=github.GithubObject.NotSet,
status=github.GithubObject.NotSet,
filter=github.GithubObject.NotSet,
):
check_name: Opt[str] = NotSet,
status: Opt[str] = NotSet,
filter: Opt[str] = NotSet,
) -> PaginatedList[CheckRun]:
"""
:calls: `GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs <https://docs.github.com/en/rest/reference/checks#list-check-runs-in-a-check-suite>`_
:param check_name: string
:param status: string
:param filter: string
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.CheckRun.CheckRun`
"""
assert check_name is github.GithubObject.NotSet or isinstance(check_name, str), check_name
assert status is github.GithubObject.NotSet or isinstance(status, str), status
assert filter is github.GithubObject.NotSet or isinstance(filter, str), filter
url_parameters = dict()
if check_name is not github.GithubObject.NotSet:
assert is_optional(check_name, str), check_name
assert is_optional(status, str), status
assert is_optional(filter, str), filter
url_parameters: dict[str, Any] = {}
if is_defined(check_name):
url_parameters["check_name"] = check_name
if status is not github.GithubObject.NotSet:
if is_defined(status):
url_parameters["status"] = status
if filter is not github.GithubObject.NotSet:
if is_defined(filter):
url_parameters["filter"] = filter
return github.PaginatedList.PaginatedList(
return PaginatedList(
github.CheckRun.CheckRun,
self._requester,
f"{self.url}/check-runs",
@@ -202,25 +232,7 @@ class CheckSuite(github.GithubObject.CompletableGithubObject):
list_item="check_runs",
)
def _initAttributes(self) -> None:
self._after = github.GithubObject.NotSet
self._app = github.GithubObject.NotSet
self._before = github.GithubObject.NotSet
self._check_runs_url = github.GithubObject.NotSet
self._conclusion = github.GithubObject.NotSet
self._created_at = github.GithubObject.NotSet
self._head_branch = github.GithubObject.NotSet
self._head_commit = github.GithubObject.NotSet
self._head_sha = github.GithubObject.NotSet
self._id = github.GithubObject.NotSet
self._latest_check_runs_count = github.GithubObject.NotSet
self._pull_requests = github.GithubObject.NotSet
self._repository = github.GithubObject.NotSet
self._status = 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 "after" in attributes: # pragma no branch
self._after = self._makeStringAttribute(attributes["after"])
if "app" in attributes: # pragma no branch
-49
View File
@@ -1,49 +0,0 @@
from datetime import datetime
from typing import Any, Dict, List
from github.CheckRun import CheckRun
from github.GitCommit import GitCommit
from github.GithubApp import GithubApp
from github.GithubObject import CompletableGithubObject
from github.PaginatedList import PaginatedList
from github.PullRequest import PullRequest
from github.Repository import Repository
class CheckSuite(CompletableGithubObject):
def __repr__(self) -> str: ...
def _initAttributes(self) -> None: ...
def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
@property
def after(self) -> str: ...
@property
def app(self) -> GithubApp: ...
@property
def before(self) -> str: ...
@property
def check_runs_url(self) -> str: ...
@property
def conclusion(self) -> str: ...
@property
def created_at(self) -> datetime: ...
@property
def head_branch(self) -> str: ...
@property
def head_commit(self) -> GitCommit: ...
@property
def head_sha(self) -> str: ...
@property
def id(self) -> int: ...
@property
def latest_check_runs_count(self) -> int: ...
@property
def pull_requests(self) -> List[PullRequest]: ...
@property
def repository(self) -> Repository: ...
@property
def status(self) -> str: ...
@property
def updated_at(self) -> datetime: ...
@property
def url(self) -> str: ...
def rerequest(self) -> bool: ...
def get_check_runs(self, check_name: str, status: str, filter: str) -> PaginatedList[CheckRun]: ...