Skip to content

Commit 10d9ac6

Browse files
committed
Remove _class_attribute and missed _strptime_attribute
1 parent e0ec86d commit 10d9ac6

File tree

3 files changed

+2
-23
lines changed

3 files changed

+2
-23
lines changed

github3/gists/comment.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def _update_attributes(self, comment):
6464
self.created_at = self._strptime(comment['created_at'])
6565
self.id = comment['id']
6666
self.updated_at = self._strptime(comment['updated_at'])
67-
self.user = self._class_attribute(
68-
comment, 'user', users.ShortUser, self,
69-
)
67+
self.user = users.ShortUser(comment['user'], self)
7068

7169
def _repr(self):
7270
return '<Gist Comment [{0}]>'.format(self.user.login)

github3/models.py

-19
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,6 @@ def _get_attribute(cls, data, attribute, fallback=None):
9494
return fallback
9595
return result
9696

97-
@classmethod
98-
def _class_attribute(cls, data, attribute, cl, *args, **kwargs):
99-
"""Return the attribute from the json data and instantiate the class.
100-
101-
:param dict data: dictionary used to put together the model or None
102-
:param str attribute: key of the attribute
103-
:param class cl: class that will be instantiated
104-
:returns: instantiated class or None
105-
:rtype: object or None
106-
"""
107-
value = cls._get_attribute(data, attribute)
108-
if value:
109-
return cl(
110-
value,
111-
*args,
112-
**kwargs
113-
)
114-
return value
115-
11697
@classmethod
11798
def _strptime_attribute(cls, data, attribute):
11899
"""Get a datetime object from a dict, return None if it wan't found.

github3/repos/release.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def _update_attributes(self, asset):
367367
self.name = asset['name']
368368
self.size = asset['size']
369369
self.state = asset['state']
370-
self.updated_at = self._strptime_attribute(asset, 'updated_at')
370+
self.updated_at = self._strptime(asset['updated_at'])
371371

372372
def _repr(self):
373373
return '<Asset [{0}]>'.format(self.name)

0 commit comments

Comments
 (0)