diff --git a/github/PullRequestComment.py b/github/PullRequestComment.py
index 484e53d8..f952fe4a 100644
--- a/github/PullRequestComment.py
+++ b/github/PullRequestComment.py
@@ -32,151 +32,127 @@
# 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 . 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} `_
: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} `_
: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
`_
: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
`_
@@ -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}
`_
@@ -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
diff --git a/github/PullRequestComment.pyi b/github/PullRequestComment.pyi
deleted file mode 100644
index 4b390df3..00000000
--- a/github/PullRequestComment.pyi
+++ /dev/null
@@ -1,47 +0,0 @@
-from datetime import datetime
-from typing import Any, Dict
-
-from github.GithubObject import CompletableGithubObject
-from github.NamedUser import NamedUser
-from github.PaginatedList import PaginatedList
-from github.Reaction import Reaction
-
-class PullRequestComment(CompletableGithubObject):
- def __repr__(self) -> str: ...
- def _initAttributes(self) -> None: ...
- def _useAttributes(self, attributes: Dict[str, Any]) -> None: ...
- @property
- def body(self) -> str: ...
- @property
- def commit_id(self) -> str: ...
- def create_reaction(self, reaction_type: str) -> Reaction: ...
- @property
- def created_at(self) -> datetime: ...
- def delete(self) -> None: ...
- def delete_reaction(self, reaction_id: int) -> bool: ...
- @property
- def diff_hunk(self) -> str: ...
- def edit(self, body: str) -> None: ...
- def get_reactions(self) -> PaginatedList[Reaction]: ...
- @property
- def html_url(self) -> str: ...
- @property
- def id(self) -> int: ...
- @property
- def in_reply_to_id(self) -> int: ...
- @property
- def original_commit_id(self) -> str: ...
- @property
- def original_position(self) -> int: ...
- @property
- def path(self) -> str: ...
- @property
- def position(self) -> int: ...
- @property
- def pull_request_url(self) -> str: ...
- @property
- def updated_at(self) -> datetime: ...
- @property
- def url(self) -> str: ...
- @property
- def user(self) -> NamedUser: ...