2021-01-10 06:08

get_comments does not return the comments created with create_issue_comments

I notice that calling get_comments on a PR object does not return the comments created with create_issue_comment, it only returns the user-based comments made with the web interface. Similarly, get_issue_comments does not return the API-created comments.

This is quite counter-intuitive.

Is that on purpose?


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • weixin_39607474 weixin_39607474 4月前

    Hi Thanks for reporting.

    Can you provide an example?

    点赞 评论 复制链接分享
  • weixin_39573535 weixin_39573535 4月前

    Steps to reproduce:

    1. post comment x with create_issue_comment
    2. get comment list with get_comments
    3. check that x in in list (this fails, x is not the list)
    点赞 评论 复制链接分享
  • weixin_39607474 weixin_39607474 4月前

    To answer your original question. Yes that's on purpose.

    From https://developer.github.com/v3/pulls/comments/:

    Pull Request review comments are comments on a portion of the unified diff. These are separate from Commit Comments (which are applied directly to a commit, outside of the Pull Request view), and Issue Comments (which do not reference a portion of the unified diff).

    So to summarize, PR review comment is different from issue comment. However, if you look at the source code, the get_comments method on PullRequest is actually an alias of get_review_comments. (probably a history problem, I don't know)

    get_issue_comments is what you want and I believe you should get what you created with create_issue_comment unless there is a caching or timing issue?

    点赞 评论 复制链接分享
  • weixin_39573535 weixin_39573535 4月前

    Thanks for the explanation.

    Created https://github.com/PyGithub/PyGithub/pull/743 to fix the issue.

    点赞 评论 复制链接分享