Improve type asserts on lists

This commit is contained in:
Vincent Jacques
2012-05-30 18:43:29 +02:00
parent b2cdba9cb5
commit 7a622975d6
12 changed files with 41 additions and 41 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ class GitTree( object ):
assert isinstance( attributes[ "sha" ], ( str, unicode ) ), attributes[ "sha" ]
self.__sha = attributes[ "sha" ]
if "tree" in attributes and attributes[ "tree" ] is not None: # pragma no branch
assert isinstance( attributes[ "tree" ], list ) and ( len( attributes[ "tree" ] ) == 0 or isinstance( attributes[ "tree" ][ 0 ], dict ) ), attributes[ "tree" ]
assert all( isinstance( element, dict ) for element in attributes[ "tree" ] ), attributes[ "tree" ]
self.__tree = [
GitTreeElement.GitTreeElement( self.__requester, element, completion = LazyCompletion )
for element in attributes[ "tree" ]