mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-02 03:41:08 +00:00
Check types of received attributes
This commit is contained in:
@@ -572,52 +572,77 @@ class AuthenticatedUser( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "avatar_url" in attributes and attributes[ "avatar_url" ] is not None:
|
||||
assert isinstance( attributes[ "avatar_url" ], ( str, unicode ) )
|
||||
self.__avatar_url = attributes[ "avatar_url" ]
|
||||
if "bio" in attributes and attributes[ "bio" ] is not None:
|
||||
assert isinstance( attributes[ "bio" ], ( str, unicode ) )
|
||||
self.__bio = attributes[ "bio" ]
|
||||
if "blog" in attributes and attributes[ "blog" ] is not None:
|
||||
assert isinstance( attributes[ "blog" ], ( str, unicode ) )
|
||||
self.__blog = attributes[ "blog" ]
|
||||
if "collaborators" in attributes and attributes[ "collaborators" ] is not None:
|
||||
assert isinstance( attributes[ "collaborators" ], int )
|
||||
self.__collaborators = attributes[ "collaborators" ]
|
||||
if "company" in attributes and attributes[ "company" ] is not None:
|
||||
assert isinstance( attributes[ "company" ], ( str, unicode ) )
|
||||
self.__company = attributes[ "company" ]
|
||||
if "created_at" in attributes and attributes[ "created_at" ] is not None:
|
||||
assert isinstance( attributes[ "created_at" ], ( str, unicode ) )
|
||||
self.__created_at = attributes[ "created_at" ]
|
||||
if "disk_usage" in attributes and attributes[ "disk_usage" ] is not None:
|
||||
assert isinstance( attributes[ "disk_usage" ], int )
|
||||
self.__disk_usage = attributes[ "disk_usage" ]
|
||||
if "email" in attributes and attributes[ "email" ] is not None:
|
||||
assert isinstance( attributes[ "email" ], ( str, unicode ) )
|
||||
self.__email = attributes[ "email" ]
|
||||
if "followers" in attributes and attributes[ "followers" ] is not None:
|
||||
assert isinstance( attributes[ "followers" ], int )
|
||||
self.__followers = attributes[ "followers" ]
|
||||
if "following" in attributes and attributes[ "following" ] is not None:
|
||||
assert isinstance( attributes[ "following" ], int )
|
||||
self.__following = attributes[ "following" ]
|
||||
if "gravatar_id" in attributes and attributes[ "gravatar_id" ] is not None:
|
||||
assert isinstance( attributes[ "gravatar_id" ], ( str, unicode ) )
|
||||
self.__gravatar_id = attributes[ "gravatar_id" ]
|
||||
if "hireable" in attributes and attributes[ "hireable" ] is not None:
|
||||
assert isinstance( attributes[ "hireable" ], bool )
|
||||
self.__hireable = attributes[ "hireable" ]
|
||||
if "html_url" in attributes and attributes[ "html_url" ] is not None:
|
||||
assert isinstance( attributes[ "html_url" ], ( str, unicode ) )
|
||||
self.__html_url = attributes[ "html_url" ]
|
||||
if "id" in attributes and attributes[ "id" ] is not None:
|
||||
assert isinstance( attributes[ "id" ], int )
|
||||
self.__id = attributes[ "id" ]
|
||||
if "location" in attributes and attributes[ "location" ] is not None:
|
||||
assert isinstance( attributes[ "location" ], ( str, unicode ) )
|
||||
self.__location = attributes[ "location" ]
|
||||
if "login" in attributes and attributes[ "login" ] is not None:
|
||||
assert isinstance( attributes[ "login" ], ( str, unicode ) )
|
||||
self.__login = attributes[ "login" ]
|
||||
if "name" in attributes and attributes[ "name" ] is not None:
|
||||
assert isinstance( attributes[ "name" ], ( str, unicode ) )
|
||||
self.__name = attributes[ "name" ]
|
||||
if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None:
|
||||
assert isinstance( attributes[ "owned_private_repos" ], int )
|
||||
self.__owned_private_repos = attributes[ "owned_private_repos" ]
|
||||
if "plan" in attributes and attributes[ "plan" ] is not None:
|
||||
assert isinstance( attributes[ "plan" ], dict )
|
||||
self.__plan = Plan.Plan( self.__requester, attributes[ "plan" ], lazy = True )
|
||||
if "private_gists" in attributes and attributes[ "private_gists" ] is not None:
|
||||
assert isinstance( attributes[ "private_gists" ], int )
|
||||
self.__private_gists = attributes[ "private_gists" ]
|
||||
if "public_gists" in attributes and attributes[ "public_gists" ] is not None:
|
||||
assert isinstance( attributes[ "public_gists" ], int )
|
||||
self.__public_gists = attributes[ "public_gists" ]
|
||||
if "public_repos" in attributes and attributes[ "public_repos" ] is not None:
|
||||
assert isinstance( attributes[ "public_repos" ], int )
|
||||
self.__public_repos = attributes[ "public_repos" ]
|
||||
if "total_private_repos" in attributes and attributes[ "total_private_repos" ] is not None:
|
||||
assert isinstance( attributes[ "total_private_repos" ], int )
|
||||
self.__total_private_repos = attributes[ "total_private_repos" ]
|
||||
if "type" in attributes and attributes[ "type" ] is not None:
|
||||
assert isinstance( attributes[ "type" ], ( str, unicode ) )
|
||||
self.__type = attributes[ "type" ]
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
assert isinstance( attributes[ "url" ], ( str, unicode ) )
|
||||
self.__url = attributes[ "url" ]
|
||||
|
||||
@@ -31,6 +31,8 @@ class Branch( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "commit" in attributes and attributes[ "commit" ] is not None:
|
||||
assert isinstance( attributes[ "commit" ], dict )
|
||||
self.__commit = Commit.Commit( self.__requester, attributes[ "commit" ], lazy = True )
|
||||
if "name" in attributes and attributes[ "name" ] is not None:
|
||||
assert isinstance( attributes[ "name" ], ( str, unicode ) )
|
||||
self.__name = attributes[ "name" ]
|
||||
|
||||
@@ -121,18 +121,23 @@ class Commit( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "author" in attributes and attributes[ "author" ] is not None:
|
||||
assert isinstance( attributes[ "author" ], dict )
|
||||
self.__author = NamedUser.NamedUser( self.__requester, attributes[ "author" ], lazy = True )
|
||||
if "commit" in attributes and attributes[ "commit" ] is not None:
|
||||
assert isinstance( attributes[ "commit" ], dict )
|
||||
self.__commit = GitCommit.GitCommit( self.__requester, attributes[ "commit" ], lazy = True )
|
||||
if "committer" in attributes and attributes[ "committer" ] is not None:
|
||||
assert isinstance( attributes[ "committer" ], dict )
|
||||
self.__committer = NamedUser.NamedUser( self.__requester, attributes[ "committer" ], lazy = True )
|
||||
if "files" in attributes and attributes[ "files" ] is not None:
|
||||
self.__files = attributes[ "files" ]
|
||||
if "parents" in attributes and attributes[ "parents" ] is not None:
|
||||
self.__parents = attributes[ "parents" ]
|
||||
if "sha" in attributes and attributes[ "sha" ] is not None:
|
||||
assert isinstance( attributes[ "sha" ], ( str, unicode ) )
|
||||
self.__sha = attributes[ "sha" ]
|
||||
if "stats" in attributes and attributes[ "stats" ] is not None:
|
||||
self.__stats = attributes[ "stats" ]
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
assert isinstance( attributes[ "url" ], ( str, unicode ) )
|
||||
self.__url = attributes[ "url" ]
|
||||
|
||||
@@ -143,4 +143,5 @@ class CommitComment( object ):
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
if "user" in attributes and attributes[ "user" ] is not None:
|
||||
assert isinstance( attributes[ "user" ], dict )
|
||||
self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True )
|
||||
|
||||
@@ -111,6 +111,7 @@ class Event( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "actor" in attributes and attributes[ "actor" ] is not None:
|
||||
assert isinstance( attributes[ "actor" ], dict )
|
||||
self.__actor = NamedUser.NamedUser( self.__requester, attributes[ "actor" ], lazy = True )
|
||||
if "commit_id" in attributes and attributes[ "commit_id" ] is not None:
|
||||
self.__commit_id = attributes[ "commit_id" ]
|
||||
@@ -123,12 +124,14 @@ class Event( object ):
|
||||
if "issue" in attributes and attributes[ "issue" ] is not None:
|
||||
self.__issue = attributes[ "issue" ]
|
||||
if "org" in attributes and attributes[ "org" ] is not None:
|
||||
assert isinstance( attributes[ "org" ], dict )
|
||||
self.__org = Organization.Organization( self.__requester, attributes[ "org" ], lazy = True )
|
||||
if "payload" in attributes and attributes[ "payload" ] is not None:
|
||||
self.__payload = attributes[ "payload" ]
|
||||
if "public" in attributes and attributes[ "public" ] is not None:
|
||||
self.__public = attributes[ "public" ]
|
||||
if "repo" in attributes and attributes[ "repo" ] is not None:
|
||||
assert isinstance( attributes[ "repo" ], dict )
|
||||
self.__repo = Repository.Repository( self.__requester, attributes[ "repo" ], lazy = True )
|
||||
if "type" in attributes and attributes[ "type" ] is not None:
|
||||
self.__type = attributes[ "type" ]
|
||||
|
||||
@@ -219,6 +219,7 @@ class Gist( object ):
|
||||
if "created_at" in attributes and attributes[ "created_at" ] is not None:
|
||||
self.__created_at = attributes[ "created_at" ]
|
||||
if "description" in attributes and attributes[ "description" ] is not None:
|
||||
assert isinstance( attributes[ "description" ], ( str, unicode ) )
|
||||
self.__description = attributes[ "description" ]
|
||||
if "files" in attributes and attributes[ "files" ] is not None:
|
||||
self.__files = attributes[ "files" ]
|
||||
@@ -233,6 +234,7 @@ class Gist( object ):
|
||||
if "html_url" in attributes and attributes[ "html_url" ] is not None:
|
||||
self.__html_url = attributes[ "html_url" ]
|
||||
if "id" in attributes and attributes[ "id" ] is not None:
|
||||
assert isinstance( attributes[ "id" ], int )
|
||||
self.__id = attributes[ "id" ]
|
||||
if "public" in attributes and attributes[ "public" ] is not None:
|
||||
self.__public = attributes[ "public" ]
|
||||
@@ -241,4 +243,5 @@ class Gist( object ):
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
if "user" in attributes and attributes[ "user" ] is not None:
|
||||
assert isinstance( attributes[ "user" ], dict )
|
||||
self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True )
|
||||
|
||||
@@ -103,4 +103,5 @@ class GistComment( object ):
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
if "user" in attributes and attributes[ "user" ] is not None:
|
||||
assert isinstance( attributes[ "user" ], dict )
|
||||
self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True )
|
||||
|
||||
@@ -89,6 +89,7 @@ class GitCommit( object ):
|
||||
if "sha" in attributes and attributes[ "sha" ] is not None:
|
||||
self.__sha = attributes[ "sha" ]
|
||||
if "tree" in attributes and attributes[ "tree" ] is not None:
|
||||
assert isinstance( attributes[ "tree" ], dict )
|
||||
self.__tree = GitTree.GitTree( self.__requester, attributes[ "tree" ], lazy = True )
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
|
||||
@@ -78,6 +78,7 @@ class GitRef( object ):
|
||||
if "object" in attributes and attributes[ "object" ] is not None:
|
||||
self.__object = attributes[ "object" ]
|
||||
if "ref" in attributes and attributes[ "ref" ] is not None:
|
||||
assert isinstance( attributes[ "ref" ], ( str, unicode ) )
|
||||
self.__ref = attributes[ "ref" ]
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
|
||||
@@ -252,6 +252,7 @@ class Issue( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "assignee" in attributes and attributes[ "assignee" ] is not None:
|
||||
assert isinstance( attributes[ "assignee" ], dict )
|
||||
self.__assignee = NamedUser.NamedUser( self.__requester, attributes[ "assignee" ], lazy = True )
|
||||
if "body" in attributes and attributes[ "body" ] is not None:
|
||||
self.__body = attributes[ "body" ]
|
||||
@@ -270,6 +271,7 @@ class Issue( object ):
|
||||
if "labels" in attributes and attributes[ "labels" ] is not None:
|
||||
self.__labels = attributes[ "labels" ]
|
||||
if "milestone" in attributes and attributes[ "milestone" ] is not None:
|
||||
assert isinstance( attributes[ "milestone" ], dict )
|
||||
self.__milestone = Milestone.Milestone( self.__requester, attributes[ "milestone" ], lazy = True )
|
||||
if "number" in attributes and attributes[ "number" ] is not None:
|
||||
self.__number = attributes[ "number" ]
|
||||
@@ -284,4 +286,5 @@ class Issue( object ):
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
if "user" in attributes and attributes[ "user" ] is not None:
|
||||
assert isinstance( attributes[ "user" ], dict )
|
||||
self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True )
|
||||
|
||||
@@ -103,4 +103,5 @@ class IssueComment( object ):
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
if "user" in attributes and attributes[ "user" ] is not None:
|
||||
assert isinstance( attributes[ "user" ], dict )
|
||||
self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True )
|
||||
|
||||
@@ -79,6 +79,7 @@ class IssueEvent( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "actor" in attributes and attributes[ "actor" ] is not None:
|
||||
assert isinstance( attributes[ "actor" ], dict )
|
||||
self.__actor = NamedUser.NamedUser( self.__requester, attributes[ "actor" ], lazy = True )
|
||||
if "commit_id" in attributes and attributes[ "commit_id" ] is not None:
|
||||
self.__commit_id = attributes[ "commit_id" ]
|
||||
|
||||
@@ -142,6 +142,7 @@ class Milestone( object ):
|
||||
if "created_at" in attributes and attributes[ "created_at" ] is not None:
|
||||
self.__created_at = attributes[ "created_at" ]
|
||||
if "creator" in attributes and attributes[ "creator" ] is not None:
|
||||
assert isinstance( attributes[ "creator" ], dict )
|
||||
self.__creator = NamedUser.NamedUser( self.__requester, attributes[ "creator" ], lazy = True )
|
||||
if "description" in attributes and attributes[ "description" ] is not None:
|
||||
self.__description = attributes[ "description" ]
|
||||
|
||||
@@ -384,6 +384,7 @@ class NamedUser( object ):
|
||||
if "email" in attributes and attributes[ "email" ] is not None:
|
||||
self.__email = attributes[ "email" ]
|
||||
if "followers" in attributes and attributes[ "followers" ] is not None:
|
||||
assert isinstance( attributes[ "followers" ], int )
|
||||
self.__followers = attributes[ "followers" ]
|
||||
if "following" in attributes and attributes[ "following" ] is not None:
|
||||
self.__following = attributes[ "following" ]
|
||||
@@ -396,10 +397,13 @@ class NamedUser( object ):
|
||||
if "id" in attributes and attributes[ "id" ] is not None:
|
||||
self.__id = attributes[ "id" ]
|
||||
if "location" in attributes and attributes[ "location" ] is not None:
|
||||
assert isinstance( attributes[ "location" ], ( str, unicode ) )
|
||||
self.__location = attributes[ "location" ]
|
||||
if "login" in attributes and attributes[ "login" ] is not None:
|
||||
assert isinstance( attributes[ "login" ], ( str, unicode ) )
|
||||
self.__login = attributes[ "login" ]
|
||||
if "name" in attributes and attributes[ "name" ] is not None:
|
||||
assert isinstance( attributes[ "name" ], ( str, unicode ) )
|
||||
self.__name = attributes[ "name" ]
|
||||
if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None:
|
||||
self.__owned_private_repos = attributes[ "owned_private_repos" ]
|
||||
|
||||
@@ -408,10 +408,13 @@ class Organization( object ):
|
||||
if "id" in attributes and attributes[ "id" ] is not None:
|
||||
self.__id = attributes[ "id" ]
|
||||
if "location" in attributes and attributes[ "location" ] is not None:
|
||||
assert isinstance( attributes[ "location" ], ( str, unicode ) )
|
||||
self.__location = attributes[ "location" ]
|
||||
if "login" in attributes and attributes[ "login" ] is not None:
|
||||
assert isinstance( attributes[ "login" ], ( str, unicode ) )
|
||||
self.__login = attributes[ "login" ]
|
||||
if "name" in attributes and attributes[ "name" ] is not None:
|
||||
assert isinstance( attributes[ "name" ], ( str, unicode ) )
|
||||
self.__name = attributes[ "name" ]
|
||||
if "owned_private_repos" in attributes and attributes[ "owned_private_repos" ] is not None:
|
||||
self.__owned_private_repos = attributes[ "owned_private_repos" ]
|
||||
|
||||
@@ -40,10 +40,14 @@ class Plan( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "collaborators" in attributes and attributes[ "collaborators" ] is not None:
|
||||
assert isinstance( attributes[ "collaborators" ], int )
|
||||
self.__collaborators = attributes[ "collaborators" ]
|
||||
if "name" in attributes and attributes[ "name" ] is not None:
|
||||
assert isinstance( attributes[ "name" ], ( str, unicode ) )
|
||||
self.__name = attributes[ "name" ]
|
||||
if "private_repos" in attributes and attributes[ "private_repos" ] is not None:
|
||||
assert isinstance( attributes[ "private_repos" ], int )
|
||||
self.__private_repos = attributes[ "private_repos" ]
|
||||
if "space" in attributes and attributes[ "space" ] is not None:
|
||||
assert isinstance( attributes[ "space" ], int )
|
||||
self.__space = attributes[ "space" ]
|
||||
|
||||
@@ -331,4 +331,5 @@ class PullRequest( object ):
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
if "user" in attributes and attributes[ "user" ] is not None:
|
||||
assert isinstance( attributes[ "user" ], dict )
|
||||
self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True )
|
||||
|
||||
@@ -143,4 +143,5 @@ class PullRequestComment( object ):
|
||||
if "url" in attributes and attributes[ "url" ] is not None:
|
||||
self.__url = attributes[ "url" ]
|
||||
if "user" in attributes and attributes[ "user" ] is not None:
|
||||
assert isinstance( attributes[ "user" ], dict )
|
||||
self.__user = NamedUser.NamedUser( self.__requester, attributes[ "user" ], lazy = True )
|
||||
|
||||
@@ -927,14 +927,17 @@ class Repository( object ):
|
||||
if "mirror_url" in attributes and attributes[ "mirror_url" ] is not None:
|
||||
self.__mirror_url = attributes[ "mirror_url" ]
|
||||
if "name" in attributes and attributes[ "name" ] is not None:
|
||||
assert isinstance( attributes[ "name" ], ( str, unicode ) )
|
||||
self.__name = attributes[ "name" ]
|
||||
if "open_issues" in attributes and attributes[ "open_issues" ] is not None:
|
||||
self.__open_issues = attributes[ "open_issues" ]
|
||||
if "organization" in attributes and attributes[ "organization" ] is not None:
|
||||
self.__organization = attributes[ "organization" ]
|
||||
if "owner" in attributes and attributes[ "owner" ] is not None:
|
||||
assert isinstance( attributes[ "owner" ], dict )
|
||||
self.__owner = NamedUser.NamedUser( self.__requester, attributes[ "owner" ], lazy = True )
|
||||
if "parent" in attributes and attributes[ "parent" ] is not None:
|
||||
assert isinstance( attributes[ "parent" ], dict )
|
||||
self.__parent = Repository( self.__requester, attributes[ "parent" ], lazy = True )
|
||||
if "permissions" in attributes and attributes[ "permissions" ] is not None:
|
||||
self.__permissions = attributes[ "permissions" ]
|
||||
@@ -945,6 +948,7 @@ class Repository( object ):
|
||||
if "size" in attributes and attributes[ "size" ] is not None:
|
||||
self.__size = attributes[ "size" ]
|
||||
if "source" in attributes and attributes[ "source" ] is not None:
|
||||
assert isinstance( attributes[ "source" ], dict )
|
||||
self.__source = Repository( self.__requester, attributes[ "source" ], lazy = True )
|
||||
if "ssh_url" in attributes and attributes[ "ssh_url" ] is not None:
|
||||
self.__ssh_url = attributes[ "ssh_url" ]
|
||||
|
||||
@@ -41,6 +41,7 @@ class Tag( object ):
|
||||
def __useAttributes( self, attributes ):
|
||||
#@todo No need to check if attribute is in attributes when attribute is mandatory
|
||||
if "commit" in attributes and attributes[ "commit" ] is not None:
|
||||
assert isinstance( attributes[ "commit" ], dict )
|
||||
self.__commit = Commit.Commit( self.__requester, attributes[ "commit" ], lazy = True )
|
||||
if "name" in attributes and attributes[ "name" ] is not None:
|
||||
self.__name = attributes[ "name" ]
|
||||
|
||||
Reference in New Issue
Block a user