mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Merge PullRequestComment type stub back to source (#2681)
This commit is contained in:
@@ -32,151 +32,127 @@
|
||||
# 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
|
||||
|
||||
from . import Consts
|
||||
import github.Reaction
|
||||
from github import Consts
|
||||
from github.GithubObject import Attribute, CompletableGithubObject, NotSet
|
||||
from github.PaginatedList import PaginatedList
|
||||
|
||||
|
||||
class PullRequestComment(github.GithubObject.CompletableGithubObject):
|
||||
class PullRequestComment(CompletableGithubObject):
|
||||
"""
|
||||
This class represents PullRequestComments. The reference can be found here https://docs.github.com/en/rest/reference/pulls#review-comments
|
||||
"""
|
||||
|
||||
def _initAttributes(self) -> None:
|
||||
self._body: Attribute[str] = NotSet
|
||||
self._commit_id: Attribute[str] = NotSet
|
||||
self._created_at: Attribute[datetime] = NotSet
|
||||
self._diff_hunk: Attribute[str] = NotSet
|
||||
self._id: Attribute[int] = NotSet
|
||||
self._in_reply_to_id: Attribute[int] = NotSet
|
||||
self._original_commit_id: Attribute[str] = NotSet
|
||||
self._original_position: Attribute[int] = NotSet
|
||||
self._path: Attribute[str] = NotSet
|
||||
self._position: Attribute[int] = NotSet
|
||||
self._pull_request_url: Attribute[str] = NotSet
|
||||
self._updated_at: Attribute[datetime] = NotSet
|
||||
self._url: Attribute[str] = NotSet
|
||||
self._html_url: Attribute[str] = NotSet
|
||||
self._user: Attribute[github.NamedUser.NamedUser] = NotSet
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.get__repr__({"id": self._id.value, "user": self._user.value})
|
||||
|
||||
@property
|
||||
def body(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def body(self) -> str:
|
||||
self._completeIfNotSet(self._body)
|
||||
return self._body.value
|
||||
|
||||
@property
|
||||
def commit_id(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def commit_id(self) -> str:
|
||||
self._completeIfNotSet(self._commit_id)
|
||||
return self._commit_id.value
|
||||
|
||||
@property
|
||||
def created_at(self):
|
||||
"""
|
||||
:type: datetime.datetime
|
||||
"""
|
||||
def created_at(self) -> datetime:
|
||||
self._completeIfNotSet(self._created_at)
|
||||
return self._created_at.value
|
||||
|
||||
@property
|
||||
def diff_hunk(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def diff_hunk(self) -> str:
|
||||
self._completeIfNotSet(self._diff_hunk)
|
||||
return self._diff_hunk.value
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""
|
||||
:type: integer
|
||||
"""
|
||||
def id(self) -> int:
|
||||
self._completeIfNotSet(self._id)
|
||||
return self._id.value
|
||||
|
||||
@property
|
||||
def in_reply_to_id(self):
|
||||
"""
|
||||
:type: integer
|
||||
"""
|
||||
def in_reply_to_id(self) -> int:
|
||||
self._completeIfNotSet(self._in_reply_to_id)
|
||||
return self._in_reply_to_id.value
|
||||
|
||||
@property
|
||||
def original_commit_id(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def original_commit_id(self) -> str:
|
||||
self._completeIfNotSet(self._original_commit_id)
|
||||
return self._original_commit_id.value
|
||||
|
||||
@property
|
||||
def original_position(self):
|
||||
"""
|
||||
:type: integer
|
||||
"""
|
||||
def original_position(self) -> int:
|
||||
self._completeIfNotSet(self._original_position)
|
||||
return self._original_position.value
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def path(self) -> str:
|
||||
self._completeIfNotSet(self._path)
|
||||
return self._path.value
|
||||
|
||||
@property
|
||||
def position(self):
|
||||
"""
|
||||
:type: integer
|
||||
"""
|
||||
def position(self) -> int:
|
||||
self._completeIfNotSet(self._position)
|
||||
return self._position.value
|
||||
|
||||
@property
|
||||
def pull_request_url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def pull_request_url(self) -> str:
|
||||
self._completeIfNotSet(self._pull_request_url)
|
||||
return self._pull_request_url.value
|
||||
|
||||
@property
|
||||
def updated_at(self):
|
||||
"""
|
||||
:type: datetime.datetime
|
||||
"""
|
||||
def updated_at(self) -> datetime:
|
||||
self._completeIfNotSet(self._updated_at)
|
||||
return self._updated_at.value
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
"""
|
||||
:type: string
|
||||
"""
|
||||
def url(self) -> str:
|
||||
self._completeIfNotSet(self._url)
|
||||
return self._url.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 user(self):
|
||||
"""
|
||||
:type: :class:`github.NamedUser.NamedUser`
|
||||
"""
|
||||
def user(self) -> github.NamedUser.NamedUser:
|
||||
self._completeIfNotSet(self._user)
|
||||
return self._user.value
|
||||
|
||||
def delete(self):
|
||||
def delete(self) -> None:
|
||||
"""
|
||||
:calls: `DELETE /repos/{owner}/{repo}/pulls/comments/{number} <https://docs.github.com/en/rest/reference/pulls#review-comments>`_
|
||||
:rtype: None
|
||||
"""
|
||||
headers, data = self._requester.requestJsonAndCheck("DELETE", self.url)
|
||||
|
||||
def edit(self, body):
|
||||
def edit(self, body: str) -> None:
|
||||
"""
|
||||
:calls: `PATCH /repos/{owner}/{repo}/pulls/comments/{number} <https://docs.github.com/en/rest/reference/pulls#review-comments>`_
|
||||
:param body: string
|
||||
@@ -189,13 +165,13 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
|
||||
headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters)
|
||||
self._useAttributes(data)
|
||||
|
||||
def get_reactions(self):
|
||||
def get_reactions(self) -> PaginatedList[github.Reaction.Reaction]:
|
||||
"""
|
||||
:calls: `GET /repos/{owner}/{repo}/pulls/comments/{number}/reactions
|
||||
<https://docs.github.com/en/rest/reference/reactions#list-reactions-for-a-pull-request-review-comment>`_
|
||||
:return: :class: :class:`github.PaginatedList.PaginatedList` of :class:`github.Reaction.Reaction`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
return PaginatedList(
|
||||
github.Reaction.Reaction,
|
||||
self._requester,
|
||||
f"{self.url}/reactions",
|
||||
@@ -203,7 +179,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
|
||||
headers={"Accept": Consts.mediaTypeReactionsPreview},
|
||||
)
|
||||
|
||||
def create_reaction(self, reaction_type):
|
||||
def create_reaction(self, reaction_type: str) -> github.Reaction.Reaction:
|
||||
"""
|
||||
:calls: `POST /repos/{owner}/{repo}/pulls/comments/{number}/reactions
|
||||
<https://docs.github.com/en/rest/reference/reactions#create-reaction-for-a-pull-request-review-comment>`_
|
||||
@@ -222,7 +198,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return github.Reaction.Reaction(self._requester, headers, data, completed=True)
|
||||
|
||||
def delete_reaction(self, reaction_id):
|
||||
def delete_reaction(self, reaction_id: int) -> bool:
|
||||
"""
|
||||
:calls: `DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}
|
||||
<https://docs.github.com/en/rest/reference/reactions#delete-a-pull-request-comment-reaction>`_
|
||||
@@ -237,24 +213,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
|
||||
)
|
||||
return status == 204
|
||||
|
||||
def _initAttributes(self) -> None:
|
||||
self._body = github.GithubObject.NotSet
|
||||
self._commit_id = github.GithubObject.NotSet
|
||||
self._created_at = github.GithubObject.NotSet
|
||||
self._diff_hunk = github.GithubObject.NotSet
|
||||
self._id = github.GithubObject.NotSet
|
||||
self._in_reply_to_id = github.GithubObject.NotSet
|
||||
self._original_commit_id = github.GithubObject.NotSet
|
||||
self._original_position = github.GithubObject.NotSet
|
||||
self._path = github.GithubObject.NotSet
|
||||
self._position = github.GithubObject.NotSet
|
||||
self._pull_request_url = github.GithubObject.NotSet
|
||||
self._updated_at = github.GithubObject.NotSet
|
||||
self._url = github.GithubObject.NotSet
|
||||
self._html_url = github.GithubObject.NotSet
|
||||
self._user = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes: Dict[str, Any]) -> None:
|
||||
def _useAttributes(self, attributes: dict[str, Any]) -> None:
|
||||
if "body" in attributes: # pragma no branch
|
||||
self._body = self._makeStringAttribute(attributes["body"])
|
||||
if "commit_id" in attributes: # pragma no branch
|
||||
|
||||
Reference in New Issue
Block a user