我正在使用PyGithub与GitHub API进行交互,并尝试在问题上获得受让人和分配者。我实现了以下代码,似乎受让人姓名和分配者名称不正确。例如,clatoolkitdev2
由clatoolkitdev
clatoolkitdev2
分配gh = Github(login_or_token = token, per_page = self.parPage)
repo = gh.get_repo(repo_name)
issue = repo.get_issue(issue_number)
issue_events = issue.get_events().get_page(page)
for event in issue_events:
assignee = event.issue.assignee
assigner = event.actor
assigner_id = str(assigner.id)
assigner_name = str(assigner.login)
assignee_name = assignee.login
print '================================================================='
print 'event ID: ' + str(event_id) + " " + issue_url
print 'assigner: %s assignee: %s' % (assigner_name, assignee_name)
。但是,我从我的代码中获得了=================================================================
event ID: 866189924 https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/32
assigner: clatoolkitdev2 assignee: clatoolkitdev2
=================================================================
event ID: 803384175 https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/25
assigner: kojiclatoolkit assignee: kojiclatoolkit
=================================================================
event ID: 803384176 https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/25
assigner: clatoolkitdev assignee: kojiclatoolkit
=================================================================
event ID: 852475091 https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/24
assigner: kojiclatoolkit assignee: kojiclatoolkit
=================================================================
event ID: 852475092 https://github.com/clatoolkitdev/GitHubIntegrationTest/issues/24
assigner: clatoolkitdev assignee: kojiclatoolkit
作为受让人和分配者。
RxJava 2
输出:
Retrofit 2
我检查了PyGithub API参考并用Google搜索找到了解决方案,但没有得到任何线索。我想知道我是否犯了愚蠢的错误或PyGithub中有错误。
答案 0 :(得分:0)
问题在于PyGithub(和您的代码)正在读取事件的actor.login
属性以获取分配者,实际上clatoolkitdev2
在您提供的API响应中。
查看PyGithub源代码,它似乎从API有效负载中找不到assigner
属性(Issue.py
和IssueEvent.py
中都没有),这让我感到震惊一个错误。