1

I am using following code to get the number of contributors of a repository

from github import Github
g = Github("*****github Access token****")
repo = g.get_repo('mui-org/material-ui')
contributors_count = repo.get_contributors().totalCount

It is giving number of contributors as 443, however, the correct number of contributors on the github website is 1077.

Can some one tell why am I getting different values?

Also, is there any other function in PyGithub to get correct number of contributors?

Arundhathi
  • 11
  • 2

2 Answers2

1

I'm bumping up against this too. I'm pretty sure the difference in the the counts is including or excluding "anonymous contributors". The GitHub endpoint accepts an anon param that can be set to True.

Looking at its source, PyGithub doesn't accept any arguments for its get_contributors method, so it doesn't currently surface anon contributors. It could be forked or patched to take it.

For my needs, I'm going to write my own method that makes a request for a repo, parses the "last" relation from the Link header and calculates based on the number of results on the last page. Still writing it, so I don't have a code sample for now.

Sorry I don't have anything more actionable for the moment.

whyderrick
  • 11
  • 2
0

This has been added since to PyGitHub. Now you just simply have to do:

repo.get_contributors(anon="true")
CaptainCsaba
  • 266
  • 2
  • 12