8000 Ensure a session is passed through to GitHubCore · pythonthings/github3.py@11ec3fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 11ec3fb

Browse files
committed
Ensure a session is passed through to GitHubCore
Unless a session (or a self) is passed through a new session might be created, which can lead to some interesting things. See sigmavirus24#770 This also adds a session class argument for PullDestination and updates the calls to it. A future commit will make the session argument of GitHubCore nonoptional. Related-to: sigmavirus24#771 Signed-off-by: Jesse Keating <omgjlk@github.com>
1 parent 785562d commit 11ec3fb

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

github3/gists/gist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class GistFork(GitHubCore):
314314
def _update_attributes(self, fork):
315315
self.created_at = self._strptime(fork['created_at'])
316316
self.id = fork['id']
317-
self.owner = users.ShortUser(fork['user'])
317+
self.owner = users.ShortUser(fork['user'], self)
318318
self.updated_at = self._strptime(fork['updated_at'])
319319
self.url = self._api = fork['url']
320320

github3/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def _update_attributes(self, tree):
193193
#: list of :class:`Hash <Hash>` objects
194194
self.tree = self._get_attribute(tree, 'tree', [])
195195
if self.tree:
196-
self.tree = [Hash(t) for t in self.tree]
196+
self.tree = [Hash(t, self) for t in self.tree]
197197

198198
def _repr(self):
199199
return '<Tree [{0}]>'.format(self.sha)

github3/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def add_email_addresses(self, addresses=[]):
8080
if addresses:
8181
url = self._build_url('user', 'emails')
8282
json = self._json(self._post(url, data=addresses), 201)
83-
return [users.Email(email) for email in json] if json else []
83+
return [users.Email(email, self) for email in json] if json else []
8484

8585
def all_events(self, number=-1, etag=None):
8686
"""Iterate over public events.

github3/issues/issue.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def _update_attributes(self, issue):
3434
#: was assigned to.
3535
self.assignee = issue['assignee']
3636
if self.assignee:
37-
self.assignee = users.ShortUser(self.assignee)
37+
self.assignee = users.ShortUser(self.assignee, self)
3838
self.assignees = issue['assignees']
3939
if self.assignees:
4040
self.assignees = [
41-
users.ShortUser(assignee) for assignee in self.assignees
41+
users.ShortUser(assignee, self) for assignee in self.assignees
4242
]
4343

4444
#: Body (description) of the issue.
@@ -107,7 +107,7 @@ def _update_attributes(self, issue):
107107
self.updated_at = self._strptime_attribute(issue, 'updated_at')
108108

109109
#: :class:`User <github3.users.User>` who opened the issue.
110-
self.user = users.ShortUser(issue['user'])
110+
self.user = users.ShortUser(issue['user'], self)
111111

112112
def _repr(self):
113113
return '<Issue [{r[0]}/{r[1]} #{n}]>'.format(r=self.repository,
@@ -389,4 +389,4 @@ def _update_attributes(self, issue):
389389
#: :class:`User <github3.users.User>` who closed the issue.
390390
self.closed_by = issue['closed_by']
391391
if self.closed_by:
392-
self.closed_by = users.ShortUser(self.closed_by)
392+
self.closed_by = users.ShortUser(self.closed_by, self)

github3/pulls.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class PullDestination(models.GitHubCore):
2424
http://developer.github.com/v3/pulls/#get-a-single-pull-request
2525
"""
2626

27-
def __init__(self, dest, direction):
28-
super(PullDestination, self).__init__(dest)
27+
def __init__(self, dest, direction, session=None):
28+
super(PullDestination, self).__init__(dest, session)
2929
from .repos.repo import ShortRepository
3030
#: Direction of the merge with respect to this destination
3131
self.direction = direction
@@ -36,7 +36,7 @@ def __init__(self, dest, direction):
3636
#: :class:`User <github3.users.User>` representing the owner
3737
self.user = None
3838
if dest.get('user'):
39-
self.user = users.ShortUser(dest.get('user'), None)
39+
self.user = users.ShortUser(dest.get('user'), self)
4040
#: SHA of the commit at the head
4141
self.sha = dest.get('sha')
4242
self._repo_name = ''
@@ -118,7 +118,7 @@ def _update_attributes(self, pull):
118118
self._api = pull['url']
119119

120120
#: Base of the merge
121-
self.base = PullDestination(pull['base'], 'Base')
121+
self.base = PullDestination(pull['base'], 'Base', self)
122122

123123
#: Body of the pull request message
124124
self.body = pull['body']
@@ -136,7 +136,7 @@ def _update_attributes(self, pull):
136136
self.created_at = self._strptime_attribute(pull, 'created_at')
137137

138138
#: The new head after the pull request
139-
self.head = PullDestination(pull['head'], 'Head')
139+
self.head = PullDestination(pull['head'], 'Head', self)
140140

141141
#: The unique id of the pull request
142142
self.id = self._get_attribute(pull, 'id')
@@ -175,7 +175,7 @@ def _update_attributes(self, pull):
175175

176176
#: :class:`User <github3.users.ShortUser>` object representing the
177177
#: creator of the pull request
178-
self.user = users.ShortUser(pull['user'])
178+
self.user = users.ShortUser(pull['user'], self)
179179

180180
# This is only present if the PR has been assigned.
181181
#: :class:`User <github3.users.ShortUser>` object representing the

github3/repos/comparison.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _update_attributes(self, compare):
6969
#: objects.
7070
self.commits = self._get_attribute(compare, 'commits', [])
7171
if self.commits:
72-
self.commits = [RepoCommit(com) for com in self.commits]
72+
self.commits = [RepoCommit(com, self) for com in self.commits]
7373

7474
#: List of dicts describing the files modified.
7575
self.files = self._get_attribute(compare, 'files', [])

github3/repos/release.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _update_attributes(self, release):
6565

6666
#: :class:`User <github3.users.ShortUser>` object representing the
6767
#: creator of the release
68-
self.author = users.ShortUser(release['author'])
68+
self.author = users.ShortUser(release['author'], self)
6969

7070
#: URLs to various attributes
7171
for urltype in ['assets_url', 'html_url', 'tarball_url',

github3/repos/status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def _update_attributes(self, combined_status):
7474
#: List of :class:`Status <github3.repos.status.Status>`
7575
#: objects.
7676
statuses = self._get_attribute(combined_status, 'statuses', [])
77-
self.statuses = [Status(s) for s in statuses]
77+
self.statuses = [Status(s, self) for s in statuses]
7878

7979
from . import repo
8080
#: Repository the combined status belongs too.

github3/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ def _update_attributes(self, user):
608608
self.total_private_repos = user['total_private_repos']
609609

610610
#: Which plan this user is on
611-
self.plan = Plan(user['plan'])
611+
self.plan = Plan(user['plan'], self)
612612

613613
#: Number of repo contributions. Only appears in ``repo.contributors``
614614
contributions = user.get('contributions')

0 commit comments

Comments
 (0)
0