Skip to content

Commit 38ca6a4

Browse files
committed
Merge remote-tracking branch 'origin/develop' into narrative-docs
Conflicts: docs/source/release-notes/1.0.0.rst
2 parents 61ae20f + 59df554 commit 38ca6a4

14 files changed

Lines changed: 236 additions & 45 deletions

File tree

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ matrix:
2727
env: TOXENV=py37
2828
- python: pypy
2929
env: TOXENV=pypy
30-
- env: TOXENV=py27-flake8
31-
- env: TOXENV=py34-flake8
30+
- python: 2.7
31+
env: TOXENV=py27-flake8
32+
- python: 3.6
33+
env: TOXENV=py36-flake8
3234
- env: TOXENV=docstrings
3335
- env: TOXENV=notebooks
3436
- env: TOXENV=readme

docs/source/release-notes/1.0.0.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ Old name New name
193193

194194
- ``github3.login`` has been simplified and split into two functions:
195195

196-
- ``github3.login`` serves the majority use case and only provides an
196+
- ``github3.login`` serves the majority use case and only provides an
197197
authenticated ``GitHub`` object.
198198

199-
- ``github3.enterprise_login`` allows GitHub Enterprise users to log into
199+
- ``github3.enterprise_login`` allows GitHub Enterprise users to log into
200200
their service.
201201

202202
- ``GitHub#iter_followers`` was split into two functions:
@@ -217,10 +217,10 @@ Old name New name
217217

218218
- ``GitHub#iter_gists`` was split into three functions:
219219

220-
- ``GitHub#public_gists`` which iterates over all of the public gists on
220+
- ``GitHub#public_gists`` which iterates over all of the public gists on
221221
GitHub
222222

223-
- ``GitHub#gists_for`` which iterates over all the public gists of a
223+
- ``GitHub#gists_for`` which iterates over all the public gists of a
224224
specific user
225225

226226
- ``GitHub#gists`` which iterates over the authenticated users gists
@@ -238,7 +238,7 @@ Old name New name
238238
- ``GitHub#subscriptions_for`` which iterates over an arbitrary user's
239239
subscriptions
240240

241-
- ``GitHub#subscriptions`` which iterates over the authenticated user's
241+
- ``GitHub#subscriptions`` which iterates over the authenticated user's
242242
subscriptions
243243

244244
- ``GitHub#iter_starred`` was split into two functions:
@@ -272,10 +272,10 @@ Old name New name
272272

273273
- ``Repository#set_subscription`` was split into two simpler functions
274274

275-
- ``Repository#subscribe`` subscribes the authenticated user to the
275+
- ``Repository#subscribe`` subscribes the authenticated user to the
276276
repository's notifications
277277

278-
- ``Repository#ignore`` ignores notifications from the repository for the
278+
- ``Repository#ignore`` ignores notifications from the repository for the
279279
authenticated user
280280

281281
- ``Repository#contents`` was split into two simpler functions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
1.1.0: 2018-04-09
2+
-----------------
3+
4+
This is a small release with some enhancments.
5+
6+
Features Added
7+
``````````````
8+
9+
- Repository collaborators now returns a ``users.Collaborator`` object, instead of
10+
a ``users.ShortUser`` object. This is to support collaborator affiliations. A
11+
refresh call of this object (and ``users.Contributor``) will result in a full
12+
``users.User`` object.
13+
14+
- The call to iterate collaborators of a repository
15+
(``Repsitory#collaborators``) can now take an ``affiliation`` filter with options of
16+
``outside``, ``direct``, and ``all``. The default is ``all``, which preserves the previous
17+
behavior of this method.
18+
19+
Bugs Fixed
20+
``````````
21+
22+
- Parse certain attributes on ``IssueEvent`` into objects (again, this was a
23+
regression in 1.0)
24+
- Handle older GitHub Enterprise responses for authenticated user objects
25+
- Handle large file pull request responses not including a ``patch`` attribute

docs/source/release-notes/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ here with the newest releases first.
99
==================
1010

1111
.. toctree::
12+
1.1.0
1213
1.0.2
1314
1.0.1
1415
1.0.0

github3/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__author_email__ = '[email protected]'
66
__license__ = 'Modified BSD'
77
__copyright__ = 'Copyright 2012-2018 Ian Stapleton Cordasco'
8-
__version__ = '1.0.2'
8+
__version__ = '1.1.0'
99
__version_info__ = tuple(int(i) for i in __version__.split('.') if i.isdigit())
1010
__url__ = 'https://github3.readthedocs.io'
1111

github3/issues/event.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,27 @@ def _update_attributes(self, event):
6666
self.actor = users.ShortUser(event['actor'], self)
6767
self.commit_id = event['commit_id']
6868
self.commit_url = event['commit_url']
69-
self.created_at = event['created_at']
69+
self.created_at = self._strptime(event['created_at'])
70+
# Only for 'assigned' and 'unassigned' events.
71+
self.assignee = event.get('assignee')
72+
if self.assignee:
73+
self.assignee = users.ShortUser(self.assignee, self)
74+
self.assigner = event.get('assigner')
75+
if self.assigner:
76+
self.assigner = users.ShortUser(self.assigner, self)
77+
78+
# Only for 'review_requested' and 'review_request_removed' events.
79+
self.review_requester = event.get('review_requester')
80+
if self.review_requester:
81+
self.review_requester = (
82+
users.ShortUser(self.review_requester, self))
83+
self.requested_reviewers = event.get('requested_reviewers')
84+
if self.requested_reviewers:
85+
self.requested_reviewers = [
86+
users.ShortUser(reviewer, self)
87+
for reviewer in self.requested_reviewers
88+
]
89+
7090
self.event = event['event']
7191
self.id = event['id']
7292
self._uniq = self.commit_id

github3/repos/repo.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,35 @@ def code_frequency(self, number=-1, etag=None):
280280
url = self._build_url('stats', 'code_frequency', base_url=self._api)
281281
return self._iter(int(number), url, list, etag=etag)
282282

283-
def collaborators(self, number=-1, etag=None):
283+
def collaborators(self, affiliation='all', number=-1, etag=None):
284284
"""Iterate over the collaborators of this repository.
285285
286+
:param str affiliation:
287+
(optional), affiliation of the collaborator to the repository.
288+
Default: "all" returns contributors with all affiliations
286289
:param int number:
287290
(optional), number of collaborators to return.
288291
Default: -1 returns all comments
289292
:param str etag:
290293
(optional), ETag from a previous request to the same endpoint
291294
:returns:
292-
generator of collaborator users
295+
generator of collaborators
293296
:rtype:
294-
:class:`~github3.users.ShortUser`
297+
:class:`~github3.users.Collaborator`
295298
"""
296299
url = self._build_url('collaborators', base_url=self._api)
297-
return self._iter(int(number), url, users.ShortUser, etag=etag)
300+
affiliations = {'outside', 'direct', 'all'}
301+
if affiliation not in affiliations:
302+
raise ValueError(
303+
(
304+
"Invalid affiliation value {!r} parameter passed, must "
305+
"be 'outside', 'direct', or 'all' (defaults to 'all')."
306+
).format(affiliation)
307+
)
308+
params = {'affiliation': affiliation}
309+
return self._iter(
310+
int(number), url, users.Collaborator, params, etag=etag
311+
)
298312

299313
def comments(self, number=-1, etag=None):
300314
"""Iterate over comments on all commits in the repository.

github3/users.py

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -505,30 +505,6 @@ def delete(self):
505505
return self._boolean(self._delete(url), 204, 403)
506506

507507

508-
class Contributor(_User):
509-
"""Object for the specialized representation of a contributor.
510-
511-
When retrieving a repository's contributors, GitHub returns the same
512-
information as a :class:`~github3.users.ShortUser` with an additional
513-
attribute:
514-
515-
.. versionadded:: 1.0.0
516-
517-
This class was added in version 1.0.0
518-
519-
.. attribute:: contributions_count
520-
521-
The number of contributions a contributor has made to the repository
522-
523-
"""
524-
525-
class_name = 'Contributor'
526-
527-
def _update_attributes(self, contributor):
528-
super(Contributor, self)._update_attributes(contributor)
529-
self.contributions = contributor['contributions']
530-
531-
532508
class User(_User):
533509
"""Object for the full representation of a User.
534510
@@ -765,3 +741,57 @@ def _update_attributes(self, user):
765741
self.plan = user.get('plan')
766742
if self.plan is not None:
767743
self.plan = Plan(self.plan, self)
744+
745+
746+
class Collaborator(_User):
747+
"""Object for the representation of a collaborator.
748+
749+
.. versionadded:: 1.1.0
750+
751+
When retrieving a repository's contributors, GitHub returns the same
752+
information as a :class:`~github3.users.ShortUser` with an additional
753+
attribute:
754+
755+
.. attribute:: permissions
756+
757+
Admin, push, and pull permissions of a collaborator
758+
"""
759+
760+
class_name = 'Collaborator'
761+
_refresh_to = User
762+
763+
def _update_attributes(self, user):
764+
super(Collaborator, self)._update_attributes(user)
765+
766+
self.permissions = user['permissions']
767+
768+
769+
class Contributor(_User):
770+
"""Object for the specialized representation of a contributor.
771+
772+
.. versionadded:: 1.0.0
773+
774+
.. versionchanged:: 1.1.0
775+
776+
This class now refreshes to a :class:`~github3.users.User`.
777+
778+
The attribute ``contributions`` was renamed to ``contributions_count``,
779+
the documentation already declared it as ``contributions_count``, it
780+
was the implementation now reflects this as well.
781+
782+
When retrieving a repository's contributors, GitHub returns the same
783+
information as a :class:`~github3.users.ShortUser` with an additional
784+
attribute:
785+
786+
.. attribute:: contributions_count
787+
788+
The number of contributions a contributor has made to the repository
789+
790+
"""
791+
792+
class_name = 'Contributor'
793+
_refresh_to = User
794+
795+
def _update_attributes(self, contributor):
796+
super(Contributor, self)._update_attributes(contributor)
797+
self.contributions_count = contributor['contributions']

0 commit comments

Comments
 (0)