通过 PyGithub 获取分配和分配

Get assignees and assigner via PyGithub

我正在使用 PyGithub 与 GitHub API 进行交互,并试图让受让人和分配者解决问题。我实现了下面的代码,似乎assignee name和assigner name不正确。例如,clatoolkitdev2clatoolkitdevissue #32 上分配。但是,我从我的代码中得到了 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

我查看了 PyGithub API 参考资料并用谷歌搜索找到解决方案,但没有得到任何线索。我想知道是我犯了愚蠢的错误还是 PyGithub 中有错误。

问题在于 PyGithub(和您的代码)正在读取事件的 actor.login 属性 以获取分配器,实际上 clatoolkitdev2 在 API 您提供的回复。

查看 PyGithub 源代码,它似乎从未从 API 有效负载中读取 assigner 属性(Issue.py nor IssueEvent.py 中也没有),这很明显我是个虫子。