Skip to content

Commit c2f12bd

Browse files
authored
Add example for Pull Request comments to documentation (#2390)
1 parent 8c4b946 commit c2f12bd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/examples/PullRequest.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,20 @@ Get Pull Requests by Query
4343
861
4444
875
4545
876
46+
47+
Add and modify Pull Request comment
48+
-----------------------------------
49+
50+
.. code-block:: python
51+
52+
>>> repo = g.get_repo("PyGithub/PyGithub")
53+
>>> pr = repo.get_pull(2390)
54+
>>> last_commit = pr.get_commits()[pr.commits - 1]
55+
>>> comment = pr.create_comment("This is a comment", last_commit, "file.txt", 0)
56+
>>> comment
57+
PullRequestComment(user=NamedUser(login="anonymous"), id=1057297855)
58+
>>> comment.body
59+
'This is a comment'
60+
>>> comment.edit("This is a modified comment")
61+
>>> comment.body
62+
'This is a modified comment'

0 commit comments

Comments
 (0)