8000 Finish up work to split up User object · jayc13/github3.py@30be3c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 30be3c6

Browse files
committed
Finish up work to split up User object
1 parent afc207e commit 30be3c6

File tree

15 files changed

+347
-65
lines changed

15 files changed

+347
-65
lines changed

github3/repos/comment.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"""
99
from __future__ import unicode_literals
1010

11+
from .. import users
12+
1113
from ..decorators import requires_auth
1214
from ..models import BaseComment
13-
from ..users import User
1415

1516

1617
class RepoComment(BaseComment):
@@ -50,7 +51,9 @@ def _update_attributes(self, comment):
5051
self.updated_at = self._strptime_attribute(comment, 'updated_at')
5152

5253
#: Login of the user who left the comment.
53-
self.user = self._class_attribute(comment, 'user', User, self)
54+
self.user = self._class_attribute(
55+
comment, 'user', users.ShortUser, self
56+
)
5457

5558
def _repr(self):
5659
return '<Repository Comment [{0}/{1}]>'.format(

github3/repos/commit.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ class RepoCommit(models.BaseCommit):
3333
def _update_attributes(self, commit):
3434
super(RepoCommit, self)._update_attributes(commit)
3535

36-
#: :class:`User <github3.users.User>` who authored the commit.
37-
self.author = self._class_attribute(commit, 'author', users.User, self)
38-
39-
#: :class:`User <github3.users.User>` who committed the commit.
36+
self.author = self._class_attribute(
37+
commit, 'author', users.ShortUser, self
38+
)
4039
self.committer = self._class_attribute(
41-
commit, 'committer', users.User, self
40+
commit, 'author', users.ShortUser, self
4241
)
4342

4443
#: :class:`Commit <github3.git.Commit>`.

github3/repos/deployment.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4+
from .. import users
5+
46
from ..models import GitHubCore
5-
from ..users import User
67

78

89
class Deployment(GitHubCore):
@@ -21,7 +22,9 @@ def _update_attributes(self, deployment):
2122
self.ref = self._get_attribute(deployment, 'ref')
2223

2324
#: User object representing the creator of the deployment
24-
self.creator = self._class_attribute(deployment, 'creator', User, self)
25+
self.creator = self._class_attribute(
26+
deployment, 'creator', users.ShortUser, self
27+
)
2528

2629
#: JSON string payload of the Deployment
2730
self.payload = self._get_attribute(deployment, 'payload')
@@ -93,7 +96,9 @@ def _update_attributes(self, status):
9396
self.state = self._get_attribute(status, 'state')
9497

9598
#: Creater of the deployment status
96-
self.creator = self._class_attribute(status, 'creator', User, self)
99+
self.creator = self._class_attribute(
100+
status, 'creator', users.ShortUser, self
101+
)
97102

98103
#: JSON payload as a string
99104
self.payload = self._get_attribute(status, 'payload', {})

github3/repos/pages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def _update_attributes(self, build):
3434
#: Error dictionary containing the error message
3535
self.error = self._get_attribute(build, 'error')
3636

37-
from ..users import User
37+
from .. import users
3838
#: :class:`User <github3.users.User>` representing who pushed the
3939
#: commit
40-
self.pusher = self._class_attribute(build, 'pusher', User)
40+
self.pusher = self._class_attribute(build, 'pusher', users.ShortUser)
4141

4242
#: SHA of the commit that triggered the build
4343
self.commit = self._get_attribute(build, 'commit')

github3/repos/stats.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
from __future__ import unicode_literals
33

44
from datetime import datetime
5+
6+
from .. import users
7+
58
from ..models import GitHubCore
6-
from ..users import User
79

810

911
def alternate_week(week):
@@ -26,7 +28,9 @@ class ContributorStats(GitHubCore):
2628

2729
def _update_attributes(self, stats_object):
2830
#: Contributor in particular that this relates to
29-
self.author = self._class_attribute(stats_object, 'author', User, self)
31+
self.author = self._class_attribute(
32+
stats_object, 'author', users.ShortUser, self
33+
)
3034
#: Total number of commits authored by ``author``.
3135
self.total = self._get_attribute(stats_object, 'total')
3236
#: List of weekly dictionaries.

github3/repos/status.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
"""
99
from __future__ import unicode_literals
1010

11+
from .. import users
12+
1113
from ..models import GitHubCore
12-
from ..users import User
1314

1415

1516
class Status(GitHubCore):
@@ -29,7 +30,9 @@ def _update_attributes(self, status):
2930
self.created_at = self._strptime_attribute(status, 'created_at')
3031

3132
#: :class:`User <github3.users.User>` who created the object
32-
self.creator = self._class_attribute(status, 'creator', User)
33+
self.creator = self._class_attribute(
34+
status, 'creator', users.ShortUser
35+
)
3336

3437
#: Short description of the Status
3538
self.description = self._get_attribute(status, 'description')

tests/integration/test_pulls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_pull_reviews(self):
113113
p = self.get_pull_request(num=671)
114114
for pull_review in p.reviews():
115115
assert isinstance(pull_review, github3.pulls.PullReview)
116-
assert isinstance(pull_review.user, github3.users.User)
116+
assert isinstance(pull_review.user, github3.users.ShortUser)
117117

118118
def test_reopen(self):
119119
"""Show that one can reopen an open Pull Request."""

tests/integration/test_repos_repo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_assignees(self):
2828
repository = self.gh.repository('kennethreitz', 'requests')
2929
assert repository is not None
3030
for assignee in repository.assignees():
31-
assert isinstance(assignee, github3.users.User)
31+
assert isinstance(assignee, github3.users.ShortUser)
3232

3333
def test_blob(self):
3434
"""Test the ability to retrieve blob on a repository."""
@@ -83,7 +83,7 @@ def test_collaborators(self):
8383
repository = self.gh.repository('sigmavirus24', 'github3.py')
8484
assert repository is not None
8585
for collaborator in repository.collaborators():
86-
assert isinstance(collaborator, github3.users.User)
86+
assert isinstance(collaborator, github3.users.ShortUser)
8787

8888
def test_comments(self):
8989
"""Test the ability to retrieve comments on a repository."""
@@ -146,7 +146,7 @@ def test_contributors(self):
146146
repository = self.gh.repository('sigmavirus24', 'github3.py')
147147
assert repository is not None
148148
for contributor in repository.contributors():
149-
assert isinstance(contributor, github3.users.User)
149+
assert isinstance(contributor, github3.users.ShortUser)
150150
assert isinstance(contributor.contributions, int)
151151

152152
def test_create_blob(self):
@@ -1017,7 +1017,7 @@ def test_stargazers(self):
10171017

10181018
assert len(stargazers) > 0
10191019
for user in stargazers:
1020-
assert isinstance(user, github3.users.User)
1020+
assert isinstance(user, github3.users.ShortUser)
10211021

10221022
def test_statuses(self):
10231023
"""Test the ability to retrieve a commit's statuses."""
@@ -1043,7 +1043,7 @@ def test_subscribers(self):
10431043

10441044
assert len(subscribers) > 0
10451045
for user in subscribers:
1046-
assert isinstance(user, github3.users.User)
1046+
assert isinstance(user, github3.users.ShortUser)
10471047

10481048
def test_subscribe(self):
10491049
"""Test the ability to subscribe to a repository's notifications."""

tests/integration/test_structs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_count_reaches_0(self):
3838
cassette_name = self.cassette_name('count_reaches_0')
3939
with self.recorder.use_cassette(cassette_name):
4040
users_iter = self.gh.all_users(number=1)
41-
assert isinstance(next(users_iter), github3.users.User)
41+
assert isinstance(next(users_iter), github3.users.ShortUser)
4242
with pytest.raises(StopIteration):
4343
next(users_iter)
4444

@@ -47,4 +47,4 @@ def test_next(self):
4747
cassette_name = self.cassette_name('next')
4848
with self.recorder.use_cassette(cassette_name):
4949
users_iter = self.gh.all_users(number=10)
50-
assert isinstance(next(users_iter), github3.users.User)
50+
assert isinstance(next(users_iter), github3.users.ShortUser)

tests/integration/test_users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_followers(self):
6060

6161
assert len(followers) > 0
6262
for follower in followers:
63-
assert isinstance(follower, github3.users.User)
63+
assert isinstance(follower, github3.users.ShortUser)
6464

6565
def test_following(self):
6666
"""Show that a user can retrieve users that a user is following."""
@@ -71,7 +71,7 @@ def test_following(self):
7171

7272
assert len(following) > 0
7373
for person in following:
74-
assert isinstance(person, github3.users.User)
74+
assert isinstance(person, github3.users.ShortUser)
7575

7676
def test_keys(self):
7777
"""Show that a user can retrieve any user's public keys."""

0 commit comments

Comments
 (0)
0