Repository: PyGithub/PyGithub

Issue:
Add the ability to filter repository collaborators
The GitHub API call for retrieving repository collaborators[allows for [filtering by affiliation](https://developer.github.com/v3/repos/collaborators/#list-collaborators).

This is not possible with the current [github.Repository.Repository.get_collaborators()](https://github.com/PyGithub/PyGithub/blob/0a10d7cdf0f69ebac6d99e9699df5696cb1e9bea/github/Repository.py#L1343-L1353) function.


Discussion:

Resolving patch:
diff --git a/github/Repository.py b/github/Repository.py
--- a/github/Repository.py
+++ b/github/Repository.py
@@ -60,6 +60,7 @@
 # Copyright 2018 per1234 <accounts@perglass.com>                               #
 # Copyright 2018 sechastain <sechastain@gmail.com>                             #
 # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
+# Copyright 2018 Vinay Hegde <vinayhegde2010@gmail.com>
 #                                                                              #
 # This file is part of PyGithub.                                               #
 # http://pygithub.readthedocs.io/                                              #
@@ -1340,16 +1341,26 @@ def get_branches(self):
             None
         )
 
-    def get_collaborators(self):
+    def get_collaborators(self, affiliation=github.GithubObject.NotSet):
         """
         :calls: `GET /repos/:owner/:repo/collaborators <http://developer.github.com/v3/repos/collaborators>`_
+        :param affiliation: string
         :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
         """
+
+        url_parameters = dict()
+        allowed_affiliations = ['outside', 'direct', 'all']
+        if affiliation is not github.GithubObject.NotSet:
+            assert isinstance(affiliation, str), affiliation
+            assert affiliation in allowed_affiliations, \
+                'Affiliation can be one of ' + ', '.join(allowed_affiliations)
+            url_parameters['affiliation'] = affiliation
+
         return github.PaginatedList.PaginatedList(
             github.NamedUser.NamedUser,
             self._requester,
             self.url + "/collaborators",
-            None
+            url_parameters
         )
 
     def get_comment(self, id):


Test patch:
diff --git a/github/tests/AllTests.py b/github/tests/AllTests.py
--- a/github/tests/AllTests.py
+++ b/github/tests/AllTests.py
@@ -20,6 +20,7 @@
 # Copyright 2018 Steve Kowalik <steven@wedontsleep.org>                        #
 # Copyright 2018 Wan Liuyang <tsfdye@gmail.com>                                #
 # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
+# Copyright 2018 Vinay Hegde <vinayhegde2010@gmail.com>
 #                                                                              #
 # This file is part of PyGithub.                                               #
 # http://pygithub.readthedocs.io/                                              #
@@ -120,3 +121,4 @@
 from Issue278 import *
 from Issue494 import *
 from Issue572 import *
+from Issue937 import *
diff --git a/github/tests/Issue937.py b/github/tests/Issue937.py
new file mode 100644
--- /dev/null
+++ b/github/tests/Issue937.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+############################ Copyrights and license ############################
+#                                                                              #
+# Copyright 2018 Vinay Hegde <vinayhegde2010@gmail.com>                        #
+#                                                                              #
+# This file is part of PyGithub.                                               #
+# http://pygithub.readthedocs.io/                                              #
+#                                                                              #
+# PyGithub is free software: you can redistribute it and/or modify it under    #
+# the terms of the GNU Lesser General Public License as published by the Free  #
+# Software Foundation, either version 3 of the License, or (at your option)    #
+# any later version.                                                           #
+#                                                                              #
+# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
+# details.                                                                     #
+#                                                                              #
+# You should have received a copy of the GNU Lesser General Public License     #
+# along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
+#                                                                              #
+################################################################################
+import Framework
+
+import github
+
+class Issue937(Framework.TestCase):
+    def setUp(self):
+        Framework.TestCase.setUp(self)
+        self.user = self.g.get_user()
+        self.repo = self.user.get_repo("PyGithub")
+
+    def testCollaboratorsAffiliation(self):
+        collaborators = self.repo.get_collaborators(affiliation='direct')
+        self.assertListKeyEqual(collaborators, lambda u: u.login, ["hegde5"])
+        with self.assertRaises(AssertionError):
+            self.repo.get_collaborators(affiliation='invalid_option')
\ No newline at end of file
diff --git a/github/tests/ReplayData/Issue937.setUp.txt b/github/tests/ReplayData/Issue937.setUp.txt
new file mode 100644
--- /dev/null
+++ b/github/tests/ReplayData/Issue937.setUp.txt
@@ -0,0 +1,22 @@
+https
+GET
+api.github.com
+None
+/user
+{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
+None
+200
+[('Server', 'GitHub.com'), ('Date', 'Sun, 21 Oct 2018 21:13:35 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4997'), ('X-RateLimit-Reset', '1540157093'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('ETag', 'W/"605a3ce7e4fb2cf76f450b75b1efd423"'), ('Last-Modified', 'Sun, 14 Oct 2018 04:50:21 GMT'), ('X-OAuth-Scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, write:discussion'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'E77D:4831:185B96E:3DA7A73:5BCCEBFE')]
+{"login":"hegde5","id":8609211,"node_id":"MDQ6VXNlcjg2MDkyMTE=","avatar_url":"https://avatars2.githubusercontent.com/u/8609211?v=4","gravatar_id":"","url":"https://api.github.com/users/hegde5","html_url":"https://github.com/hegde5","followers_url":"https://api.github.com/users/hegde5/followers","following_url":"https://api.github.com/users/hegde5/following{/other_user}","gists_url":"https://api.github.com/users/hegde5/gists{/gist_id}","starred_url":"https://api.github.com/users/hegde5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hegde5/subscriptions","organizations_url":"https://api.github.com/users/hegde5/orgs","repos_url":"https://api.github.com/users/hegde5/repos","events_url":"https://api.github.com/users/hegde5/events{/privacy}","received_events_url":"https://api.github.com/users/hegde5/received_events","type":"User","site_admin":false,"name":"Vinay Hegde","company":null,"blog":"","location":"Munich","email":null,"hireable":true,"bio":null,"public_repos":11,"public_gists":0,"followers":0,"following":6,"created_at":"2014-09-01T00:57:39Z","updated_at":"2018-10-14T04:50:21Z","private_gists":1,"total_private_repos":0,"owned_private_repos":0,"disk_usage":54332,"collaborators":0,"two_factor_authentication":true,"plan":{"name":"free","space":976562499,"collaborators":0,"private_repos":0}}
+
+https
+GET
+api.github.com
+None
+/repos/hegde5/PyGithub
+{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
+None
+200
+[('Server', 'GitHub.com'), ('Date', 'Sun, 21 Oct 2018 21:13:35 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4996'), ('X-RateLimit-Reset', '1540157093'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('ETag', 'W/"03485dc4f57e5d0f70d3a97dfdf1be37"'), ('Last-Modified', 'Sun, 21 Oct 2018 20:22:32 GMT'), ('X-OAuth-Scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, write:discussion'), ('X-Accepted-OAuth-Scopes', 'repo'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'E77F:4832:2D5ED9C:66CB081:5BCCEBFF')]
+{"id":153993221,"node_id":"MDEwOlJlcG9zaXRvcnkxNTM5OTMyMjE=","name":"PyGithub","full_name":"hegde5/PyGithub","private":false,"owner":{"login":"hegde5","id":8609211,"node_id":"MDQ6VXNlcjg2MDkyMTE=","avatar_url":"https://avatars2.githubusercontent.com/u/8609211?v=4","gravatar_id":"","url":"https://api.github.com/users/hegde5","html_url":"https://github.com/hegde5","followers_url":"https://api.github.com/users/hegde5/followers","following_url":"https://api.github.com/users/hegde5/following{/other_user}","gists_url":"https://api.github.com/users/hegde5/gists{/gist_id}","starred_url":"https://api.github.com/users/hegde5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hegde5/subscriptions","organizations_url":"https://api.github.com/users/hegde5/orgs","repos_url":"https://api.github.com/users/hegde5/repos","events_url":"https://api.github.com/users/hegde5/events{/privacy}","received_events_url":"https://api.github.com/users/hegde5/received_events","type":"User","site_admin":false},"html_url":"https://github.com/hegde5/PyGithub","description":"Description edited by PyGithub","fork":true,"url":"https://api.github.com/repos/hegde5/PyGithub","forks_url":"https://api.github.com/repos/hegde5/PyGithub/forks","keys_url":"https://api.github.com/repos/hegde5/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hegde5/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hegde5/PyGithub/teams","hooks_url":"https://api.github.com/repos/hegde5/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/hegde5/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/hegde5/PyGithub/events","assignees_url":"https://api.github.com/repos/hegde5/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/hegde5/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/hegde5/PyGithub/tags","blobs_url":"https://api.github.com/repos/hegde5/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hegde5/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hegde5/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/hegde5/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hegde5/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/hegde5/PyGithub/languages","stargazers_url":"https://api.github.com/repos/hegde5/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/hegde5/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/hegde5/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/hegde5/PyGithub/subscription","commits_url":"https://api.github.com/repos/hegde5/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/hegde5/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/hegde5/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/hegde5/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/hegde5/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/hegde5/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hegde5/PyGithub/merges","archive_url":"https://api.github.com/repos/hegde5/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hegde5/PyGithub/downloads","issues_url":"https://api.github.com/repos/hegde5/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/hegde5/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/hegde5/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/hegde5/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hegde5/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/hegde5/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/hegde5/PyGithub/deployments","created_at":"2018-10-21T09:44:20Z","updated_at":"2018-10-21T20:22:32Z","pushed_at":"2018-10-21T20:20:42Z","git_url":"git://github.com/hegde5/PyGithub.git","ssh_url":"git@github.com:hegde5/PyGithub.git","clone_url":"https://github.com/hegde5/PyGithub.git","svn_url":"https://github.com/hegde5/PyGithub","homepage":"http://vincent-jacques.net/PyGithub","size":11452,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"parent":{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars0.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2018-10-20T14:47:23Z","pushed_at":"2018-10-21T20:20:43Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":11433,"stargazers_count":2143,"watchers_count":2143,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":737,"mirror_url":null,"archived":false,"open_issues_count":51,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":737,"open_issues":51,"watchers":2143,"default_branch":"master"},"source":{"id":3544490,"node_id":"MDEwOlJlcG9zaXRvcnkzNTQ0NDkw","name":"PyGithub","full_name":"PyGithub/PyGithub","private":false,"owner":{"login":"PyGithub","id":11288996,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjg4OTk2","avatar_url":"https://avatars0.githubusercontent.com/u/11288996?v=4","gravatar_id":"","url":"https://api.github.com/users/PyGithub","html_url":"https://github.com/PyGithub","followers_url":"https://api.github.com/users/PyGithub/followers","following_url":"https://api.github.com/users/PyGithub/following{/other_user}","gists_url":"https://api.github.com/users/PyGithub/gists{/gist_id}","starred_url":"https://api.github.com/users/PyGithub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PyGithub/subscriptions","organizations_url":"https://api.github.com/users/PyGithub/orgs","repos_url":"https://api.github.com/users/PyGithub/repos","events_url":"https://api.github.com/users/PyGithub/events{/privacy}","received_events_url":"https://api.github.com/users/PyGithub/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/PyGithub/PyGithub","description":"Typed interactions with the GitHub API v3","fork":false,"url":"https://api.github.com/repos/PyGithub/PyGithub","forks_url":"https://api.github.com/repos/PyGithub/PyGithub/forks","keys_url":"https://api.github.com/repos/PyGithub/PyGithub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PyGithub/PyGithub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PyGithub/PyGithub/teams","hooks_url":"https://api.github.com/repos/PyGithub/PyGithub/hooks","issue_events_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/events{/number}","events_url":"https://api.github.com/repos/PyGithub/PyGithub/events","assignees_url":"https://api.github.com/repos/PyGithub/PyGithub/assignees{/user}","branches_url":"https://api.github.com/repos/PyGithub/PyGithub/branches{/branch}","tags_url":"https://api.github.com/repos/PyGithub/PyGithub/tags","blobs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PyGithub/PyGithub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PyGithub/PyGithub/git/refs{/sha}","trees_url":"https://api.github.com/repos/PyGithub/PyGithub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PyGithub/PyGithub/statuses/{sha}","languages_url":"https://api.github.com/repos/PyGithub/PyGithub/languages","stargazers_url":"https://api.github.com/repos/PyGithub/PyGithub/stargazers","contributors_url":"https://api.github.com/repos/PyGithub/PyGithub/contributors","subscribers_url":"https://api.github.com/repos/PyGithub/PyGithub/subscribers","subscription_url":"https://api.github.com/repos/PyGithub/PyGithub/subscription","commits_url":"https://api.github.com/repos/PyGithub/PyGithub/commits{/sha}","git_commits_url":"https://api.github.com/repos/PyGithub/PyGithub/git/commits{/sha}","comments_url":"https://api.github.com/repos/PyGithub/PyGithub/comments{/number}","issue_comment_url":"https://api.github.com/repos/PyGithub/PyGithub/issues/comments{/number}","contents_url":"https://api.github.com/repos/PyGithub/PyGithub/contents/{+path}","compare_url":"https://api.github.com/repos/PyGithub/PyGithub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PyGithub/PyGithub/merges","archive_url":"https://api.github.com/repos/PyGithub/PyGithub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PyGithub/PyGithub/downloads","issues_url":"https://api.github.com/repos/PyGithub/PyGithub/issues{/number}","pulls_url":"https://api.github.com/repos/PyGithub/PyGithub/pulls{/number}","milestones_url":"https://api.github.com/repos/PyGithub/PyGithub/milestones{/number}","notifications_url":"https://api.github.com/repos/PyGithub/PyGithub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PyGithub/PyGithub/labels{/name}","releases_url":"https://api.github.com/repos/PyGithub/PyGithub/releases{/id}","deployments_url":"https://api.github.com/repos/PyGithub/PyGithub/deployments","created_at":"2012-02-25T12:53:47Z","updated_at":"2018-10-20T14:47:23Z","pushed_at":"2018-10-21T20:20:43Z","git_url":"git://github.com/PyGithub/PyGithub.git","ssh_url":"git@github.com:PyGithub/PyGithub.git","clone_url":"https://github.com/PyGithub/PyGithub.git","svn_url":"https://github.com/PyGithub/PyGithub","homepage":"https://pygithub.readthedocs.io/","size":11433,"stargazers_count":2143,"watchers_count":2143,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":737,"mirror_url":null,"archived":false,"open_issues_count":51,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":737,"open_issues":51,"watchers":2143,"default_branch":"master"},"network_count":737,"subscribers_count":1}
+
diff --git a/github/tests/ReplayData/Issue937.testCollaboratorsAffiliation.txt b/github/tests/ReplayData/Issue937.testCollaboratorsAffiliation.txt
new file mode 100644
--- /dev/null
+++ b/github/tests/ReplayData/Issue937.testCollaboratorsAffiliation.txt
@@ -0,0 +1,11 @@
+https
+GET
+api.github.com
+None
+/repos/hegde5/PyGithub/collaborators?affiliation=direct
+{'Authorization': 'Basic login_and_password_removed', 'User-Agent': 'PyGithub/Python'}
+None
+200
+[('Server', 'GitHub.com'), ('Date', 'Sun, 21 Oct 2018 21:13:36 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Status', '200 OK'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4995'), ('X-RateLimit-Reset', '1540157093'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP'), ('ETag', 'W/"db23c025efd980c5fc4249cde2e34de0"'), ('X-OAuth-Scopes', 'admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, write:discussion'), ('X-Accepted-OAuth-Scopes', ''), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('Access-Control-Expose-Headers', 'ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '1; mode=block'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'E700:4832:2D5EDDC:66CB0FA:5BCCEC00')]
+[{"login":"hegde5","id":8609211,"node_id":"MDQ6VXNlcjg2MDkyMTE=","avatar_url":"https://avatars2.githubusercontent.com/u/8609211?v=4","gravatar_id":"","url":"https://api.github.com/users/hegde5","html_url":"https://github.com/hegde5","followers_url":"https://api.github.com/users/hegde5/followers","following_url":"https://api.github.com/users/hegde5/following{/other_user}","gists_url":"https://api.github.com/users/hegde5/gists{/gist_id}","starred_url":"https://api.github.com/users/hegde5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hegde5/subscriptions","organizations_url":"https://api.github.com/users/hegde5/orgs","repos_url":"https://api.github.com/users/hegde5/repos","events_url":"https://api.github.com/users/hegde5/events{/privacy}","received_events_url":"https://api.github.com/users/hegde5/received_events","type":"User","site_admin":false,"permissions":{"admin":true,"push":true,"pull":true}}]
+