MCPcopy
hub / github.com/PyGithub/PyGithub / create_review_comment

Method create_review_comment

github/PullRequest.py:463–517  ·  view source on GitHub ↗

:calls: `POST /repos/{owner}/{repo}/pulls/{pull_number}/comments `_

(
        self,
        body: str,
        commit: github.Commit.Commit | str,
        path: str,
        # line replaces deprecated position argument, so we put it between path and side
        line: Opt[int] = NotSet,
        side: Opt[str] = NotSet,
        start_line: Opt[int] = NotSet,
        start_side: Opt[str] = NotSet,
        in_reply_to: Opt[int] = NotSet,
        subject_type: Opt[str] = NotSet,
        as_suggestion: bool = False,
    )

Source from the content-addressed store, hash-verified

461 return self.create_review_comment(body, commit, path, position)
462
463 def create_review_comment(
464 self,
465 body: str,
466 commit: github.Commit.Commit | str,
467 path: str,
468 # line replaces deprecated position argument, so we put it between path and side
469 line: Opt[int] = NotSet,
470 side: Opt[str] = NotSet,
471 start_line: Opt[int] = NotSet,
472 start_side: Opt[str] = NotSet,
473 in_reply_to: Opt[int] = NotSet,
474 subject_type: Opt[str] = NotSet,
475 as_suggestion: bool = False,
476 ) -> PullRequestComment:
477 """
478 :calls: `POST /repos/{owner}/{repo}/pulls/{pull_number}/comments <https://docs.github.com/en/rest/reference/pulls#review-comments>`_
479 """
480 assert isinstance(body, str), body
481 assert isinstance(commit, (github.Commit.Commit, str)), commit
482 assert isinstance(path, str), path
483 assert is_optional(line, int), line
484 assert is_undefined(side) or side in ["LEFT", "RIGHT"], side
485 assert is_optional(start_line, int), start_line
486 assert is_undefined(start_side) or start_side in [
487 "LEFT",
488 "RIGHT",
489 "side",
490 ], start_side
491 assert is_optional(in_reply_to, int), in_reply_to
492 assert is_undefined(subject_type) or subject_type in [
493 "line",
494 "file",
495 ], subject_type
496 assert isinstance(as_suggestion, bool), as_suggestion
497
498 commit_id = commit._identity if isinstance(commit, github.Commit.Commit) else commit
499
500 if as_suggestion:
501 body = f"```suggestion\n{body}\n```"
502 post_parameters = NotSet.remove_unset_items(
503 {
504 "body": body,
505 "commit_id": commit_id,
506 "path": path,
507 "line": line,
508 "side": side,
509 "start_line": start_line,
510 "start_side": start_side,
511 "in_reply_to": in_reply_to,
512 "subject_type": subject_type,
513 }
514 )
515
516 headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/comments", input=post_parameters)
517 return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True)
518
519 def create_review_comment_reply(self, comment_id: int, body: str) -> PullRequestComment:
520 """

Calls 4

is_optionalFunction · 0.90
is_undefinedFunction · 0.90
remove_unset_itemsMethod · 0.80
requestJsonAndCheckMethod · 0.80

Tested by

no test coverage detected