Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用PyGithub/PullRequest创建多行注释。create_review()_Python_Git_Pull Request_Pygithub - Fatal编程技术网

Python 无法使用PyGithub/PullRequest创建多行注释。create_review()

Python 无法使用PyGithub/PullRequest创建多行注释。create_review(),python,git,pull-request,pygithub,Python,Git,Pull Request,Pygithub,我试图通过使用PyGithub/PullRequest.py中定义的create_review()函数将自动测试结果发布到pull请求中,从而实现向学生报告自动测试结果的工作流自动化。以下是我的简单代码片段: #!/usr/bin/env python import os import sys from github import Github if __name__ == "__main__": url = sys.argv[1] # create the gh

我试图通过使用PyGithub/PullRequest.py中定义的create_review()函数将自动测试结果发布到pull请求中,从而实现向学生报告自动测试结果的工作流自动化。以下是我的简单代码片段:

#!/usr/bin/env python
import os
import sys
from github import Github

if __name__ == "__main__":
   url = sys.argv[1]

# create the gh access
gh = Github("7c841411d84ce30f6c09a15ce283aa11f73f8da2");

repo = gh.get_organization('ADEN-GHCL-PILOT').get_repos(url)[0]
print(repo)

pr = repo.get_pulls(state='open')[0]
print(pr)

tresults = "this is a test of a multi-line comment|this should be the second line".split('|')
print(tresults)
pr.create_review(comments=tresults)
这将产生以下输出:

% ./add_pull_request_comment.py https://github.com/ADEN-GHCL-PILOT/hw1-test-swm-tc1.git
Repository(full_name="ADEN-GHCL-PILOT/hw1-test-swm-tc1")
PullRequest(title="Feedback", number=1)
['this is a test of a multi-line comment', 'this should be the second line']
Traceback (most recent call last):
  File "./add_pull_request_comment.py", line 20, in <module>
    pr.create_review(comments=tresults)
  File "/Users/Scott/anaconda3/lib/python3.7/site-packages/github/PullRequest.py", line 493, in create_review
    "POST", self.url + "/reviews", input=post_parameters
  File "/Users/Scott/anaconda3/lib/python3.7/site-packages/github/Requester.py", line 319, in requestJsonAndCheck
    verb, url, parameters, headers, input, self.__customConnection(url)
  File "/Users/Scott/anaconda3/lib/python3.7/site-packages/github/Requester.py", line 342, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 422 {"message": "Invalid request.\n\nFor 'items', \"this is a test of a multi-line comment\" is not an object.\nFor 'items', \"this should be the second line\" is not an object.", "documentation_url": "https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review"}
%./add\u pull\u request\u comment.pyhttps://github.com/ADEN-GHCL-PILOT/hw1-test-swm-tc1.git
存储库(全名=“ADEN-GHCL-PILOT/hw1-test-swm-tc1”)
PullRequest(title=“Feedback”,number=1)
[“这是对多行注释的测试”,“这应该是第二行”]
回溯(最近一次呼叫最后一次):
文件“/add\u pull\u request\u comment.py”,第20行,在
pr.create_review(评论=结果)
文件“/Users/Scott/anaconda3/lib/python3.7/site packages/github/PullRequest.py”,第493行,在create_review中
“POST”,self.url+“/reviews”,输入=POST\u参数
文件“/Users/Scott/anaconda3/lib/python3.7/site packages/github/Requester.py”,第319行,位于requestJsonAndCheck中
动词、url、参数、标题、输入、self.\u自定义连接(url)
文件“/Users/Scott/anaconda3/lib/python3.7/site packages/github/Requester.py”,第342行,检查
引发自我。创建异常(状态、响应负责人、输出)
github.GithubException.GithubException:422{“消息”:“请求无效。\n\n对于'items',\“这是对多行注释的测试\”不是对象。\n对于'items',\“这应该是第二行\”不是对象。“,“文档\ url”:”https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review“}
输出显示存储库和拉取请求都存在,并且注释输入应该是一个列表,它是

我被难住了。。。并将感激地接受任何指导

下午4:34更新:

我发现create_评论期望注释是注释对象列表,而不是字符串列表。其中包括文件的路径、文件中的行位置,然后是正文。我知道使用create_review_comment()创建comment对象,但由于路径无效,此操作失败