mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Use a special value for not set attributes and parameters
This commit is contained in:
+14
-14
@@ -8,34 +8,34 @@ import GitTreeElement
|
||||
class GitTree( GithubObject.GithubObject ):
|
||||
@property
|
||||
def sha( self ):
|
||||
self._completeIfNeeded( self._sha )
|
||||
return self._sha
|
||||
self._completeIfNotSet( self._sha )
|
||||
return self._NoneIfNotSet( self._sha )
|
||||
|
||||
@property
|
||||
def tree( self ):
|
||||
self._completeIfNeeded( self._tree )
|
||||
return self._tree
|
||||
self._completeIfNotSet( self._tree )
|
||||
return self._NoneIfNotSet( self._tree )
|
||||
|
||||
@property
|
||||
def url( self ):
|
||||
self._completeIfNeeded( self._url )
|
||||
return self._url
|
||||
self._completeIfNotSet( self._url )
|
||||
return self._NoneIfNotSet( self._url )
|
||||
|
||||
def _initAttributes( self ):
|
||||
self._sha = None
|
||||
self._tree = None
|
||||
self._url = None
|
||||
self._sha = GithubObject.NotSet
|
||||
self._tree = GithubObject.NotSet
|
||||
self._url = GithubObject.NotSet
|
||||
|
||||
def _useAttributes( self, attributes ):
|
||||
if "sha" in attributes and attributes[ "sha" ] is not None: # pragma no branch
|
||||
assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
|
||||
if "sha" in attributes: # pragma no branch
|
||||
assert attributes[ "sha" ] is None or isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
|
||||
self._sha = attributes[ "sha" ]
|
||||
if "tree" in attributes and attributes[ "tree" ] is not None: # pragma no branch
|
||||
if "tree" in attributes: # pragma no branch
|
||||
assert all( isinstance( element, dict ) for element in attributes[ "tree" ] ), attributes[ "tree" ]
|
||||
self._tree = [
|
||||
GitTreeElement.GitTreeElement( self._requester, element, completed = False )
|
||||
for element in attributes[ "tree" ]
|
||||
]
|
||||
if "url" in attributes and attributes[ "url" ] is not None: # pragma no branch
|
||||
assert isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
|
||||
if "url" in attributes: # pragma no branch
|
||||
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
|
||||
self._url = attributes[ "url" ]
|
||||
|
||||
Reference in New Issue
Block a user