mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Use ValuedAttribute and NotSet.value (preparation for #195)
This commit is contained in:
@@ -33,9 +33,16 @@ import Consts
|
||||
class _NotSetType:
|
||||
def __repr__(self):
|
||||
return "NotSet"
|
||||
|
||||
value = None
|
||||
NotSet = _NotSetType()
|
||||
|
||||
|
||||
class ValuedAttribute:
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
|
||||
class GithubObject(object):
|
||||
"""
|
||||
Base class for all classes representing objects returned by the API.
|
||||
@@ -87,13 +94,6 @@ class GithubObject(object):
|
||||
def _parentUrl(url):
|
||||
return "/".join(url.split("/")[: -1])
|
||||
|
||||
@staticmethod
|
||||
def _NoneIfNotSet(value):
|
||||
if value is NotSet:
|
||||
return None
|
||||
else:
|
||||
return value
|
||||
|
||||
@staticmethod
|
||||
def _parseDatetime(s):
|
||||
if s is None:
|
||||
@@ -141,7 +141,7 @@ class CompletableGithubObject(GithubObject):
|
||||
def __complete(self):
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self._url
|
||||
self._url.value
|
||||
)
|
||||
self._storeAndUseAttributes(headers, data)
|
||||
self.__completed = True
|
||||
@@ -159,7 +159,7 @@ class CompletableGithubObject(GithubObject):
|
||||
|
||||
status, responseHeaders, output = self._requester.requestJson(
|
||||
"GET",
|
||||
self._url,
|
||||
self._url.value,
|
||||
headers=conditionalRequestHeader
|
||||
)
|
||||
if status == 304:
|
||||
|
||||
Reference in New Issue
Block a user