diff --git a/CodeGenerator/templates/GithubObject.py b/CodeGenerator/templates/GithubObject.py index 5cc83895..08dfcfc6 100644 --- a/CodeGenerator/templates/GithubObject.py +++ b/CodeGenerator/templates/GithubObject.py @@ -72,8 +72,18 @@ class {{ class.name }}( object ): {% for attribute in class.attributes|dictsort:"name" %} if "{{ attribute.name }}" in attributes and attributes[ "{{ attribute.name }}" ] is not None: {% if attribute.type.simple %} + {% if attribute.type.name == "string" %} + assert isinstance( attributes[ "{{ attribute.name }}" ], ( str, unicode ) ) + {% endif %} + {% if attribute.type.name == "integer" %} + assert isinstance( attributes[ "{{ attribute.name }}" ], int ) + {% endif %} + {% if attribute.type.name == "bool" %} + assert isinstance( attributes[ "{{ attribute.name }}" ], bool ) + {% endif %} self.__{{ attribute.name }} = attributes[ "{{ attribute.name }}" ] {% else %} + assert isinstance( attributes[ "{{ attribute.name }}" ], dict ) self.__{{ attribute.name }} = {% if attribute.type.name != class.name %}{{ attribute.type.name }}.{% endif %}{{ attribute.type.name }}( self.__requester, attributes[ "{{ attribute.name }}" ], lazy = True ) {% endif %} diff --git a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json index d2094b78..00f06a2d 100644 --- a/JsonDescriptionOfGithubApiV3/description.000.human_readable.json +++ b/JsonDescriptionOfGithubApiV3/description.000.human_readable.json @@ -3,10 +3,10 @@ { "name": "Plan", "attributes": [ - { "name": "collaborators", "type": "@todo" }, - { "name": "private_repos", "type": "@todo" }, - { "name": "name", "type": "@todo" }, - { "name": "space", "type": "@todo" } + { "name": "collaborators", "type": "integer" }, + { "name": "private_repos", "type": "integer" }, + { "name": "name", "type": "string" }, + { "name": "space", "type": "integer" } ], "collections": [ ] @@ -25,31 +25,31 @@ ] }, "attributes": [ - { "name": "avatar_url", "type": "@todo" }, - { "name": "bio", "type": "@todo" }, - { "name": "blog", "type": "@todo" }, - { "name": "collaborators", "type": "@todo" }, - { "name": "company", "type": "@todo" }, - { "name": "created_at", "type": "@todo" }, - { "name": "disk_usage", "type": "@todo" }, - { "name": "email", "type": "@todo" }, - { "name": "followers", "type": "@todo" }, - { "name": "following", "type": "@todo" }, - { "name": "gravatar_id", "type": "@todo" }, - { "name": "hireable", "type": "@todo" }, - { "name": "html_url", "type": "@todo" }, - { "name": "id", "type": "@todo" }, + { "name": "avatar_url", "type": "string" }, + { "name": "bio", "type": "string" }, + { "name": "blog", "type": "string" }, + { "name": "collaborators", "type": "integer" }, + { "name": "company", "type": "string" }, + { "name": "created_at", "type": "string" }, + { "name": "disk_usage", "type": "integer" }, + { "name": "email", "type": "string" }, + { "name": "followers", "type": "integer" }, + { "name": "following", "type": "integer" }, + { "name": "gravatar_id", "type": "string" }, + { "name": "hireable", "type": "bool" }, + { "name": "html_url", "type": "string" }, + { "name": "id", "type": "integer" }, { "name": "location", "type": "string" }, { "name": "login", "type": "string" }, { "name": "name", "type": "string" }, - { "name": "owned_private_repos", "type": "@todo" }, + { "name": "owned_private_repos", "type": "integer" }, { "name": "plan", "type": "Plan" }, - { "name": "private_gists", "type": "@todo" }, - { "name": "public_gists", "type": "@todo" }, - { "name": "public_repos", "type": "@todo" }, - { "name": "total_private_repos", "type": "@todo" }, - { "name": "type", "type": "@todo" }, - { "name": "url", "type": "@todo" } + { "name": "private_gists", "type": "integer" }, + { "name": "public_gists", "type": "integer" }, + { "name": "public_repos", "type": "integer" }, + { "name": "total_private_repos", "type": "integer" }, + { "name": "type", "type": "string" }, + { "name": "url", "type": "string" } ], "collections": [ { @@ -127,7 +127,7 @@ { "name": "has_issues", "type": "bool" }, { "name": "has_wiki", "type": "bool" }, { "name": "has_downloads", "type": "bool" }, - { "name": "team_id", "type": "int", "@todo": "Use Team" } + { "name": "team_id", "type": "@todo" } ] } }, @@ -985,7 +985,7 @@ { "name": "has_issues", "type": "bool" }, { "name": "has_wiki", "type": "bool" }, { "name": "has_downloads", "type": "bool" }, - { "name": "team_id", "type": "int", "@todo": "Use Team" } + { "name": "team_id", "type": "@todo" } ] } }, diff --git a/JsonDescriptionOfGithubApiV3/description.001.normalized.json b/JsonDescriptionOfGithubApiV3/description.001.normalized.json index 6fb15ea8..30255f7a 100644 --- a/JsonDescriptionOfGithubApiV3/description.001.normalized.json +++ b/JsonDescriptionOfGithubApiV3/description.001.normalized.json @@ -6,7 +6,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "avatar_url" }, @@ -14,7 +14,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "bio" }, @@ -22,7 +22,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "blog" }, @@ -30,7 +30,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "collaborators" }, @@ -38,7 +38,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "company" }, @@ -46,7 +46,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "created_at" }, @@ -54,7 +54,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "disk_usage" }, @@ -62,7 +62,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "email" }, @@ -70,7 +70,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "followers" }, @@ -78,7 +78,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "following" }, @@ -86,7 +86,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "gravatar_id" }, @@ -94,7 +94,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "bool" }, "name": "hireable" }, @@ -102,7 +102,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "html_url" }, @@ -110,7 +110,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "id" }, @@ -142,7 +142,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "owned_private_repos" }, @@ -158,7 +158,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "private_gists" }, @@ -166,7 +166,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "public_gists" }, @@ -174,7 +174,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "public_repos" }, @@ -182,7 +182,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "total_private_repos" }, @@ -190,7 +190,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "type" }, @@ -198,7 +198,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "url" } @@ -672,9 +672,9 @@ }, { "type": { - "simple": false, + "simple": true, "cardinality": "scalar", - "name": "int" + "name": "@todo" }, "name": "team_id" } @@ -5798,9 +5798,9 @@ }, { "type": { - "simple": false, + "simple": true, "cardinality": "scalar", - "name": "int" + "name": "@todo" }, "name": "team_id" } @@ -6068,7 +6068,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "collaborators" }, @@ -6076,7 +6076,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "string" }, "name": "name" }, @@ -6084,7 +6084,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "private_repos" }, @@ -6092,7 +6092,7 @@ "type": { "simple": true, "cardinality": "scalar", - "name": "@todo" + "name": "integer" }, "name": "space" } diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 31ac50ea..edd6e9ea 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -14,31 +14,31 @@ Class `AuthenticatedUser` Attributes ---------- -* `avatar_url` -* `bio` -* `blog` -* `collaborators` -* `company` -* `created_at` -* `disk_usage` -* `email` -* `followers` -* `following` -* `gravatar_id` -* `hireable` -* `html_url` -* `id` +* `avatar_url`: string +* `bio`: string +* `blog`: string +* `collaborators`: integer +* `company`: string +* `created_at`: string +* `disk_usage`: integer +* `email`: string +* `followers`: integer +* `following`: integer +* `gravatar_id`: string +* `hireable`: bool +* `html_url`: string +* `id`: integer * `location`: string * `login`: string * `name`: string -* `owned_private_repos` +* `owned_private_repos`: integer * `plan`: `Plan` -* `private_gists` -* `public_gists` -* `public_repos` -* `total_private_repos` -* `type` -* `url` +* `private_gists`: integer +* `public_gists`: integer +* `public_repos`: integer +* `total_private_repos`: integer +* `type`: string +* `url`: string Authorizations -------------- @@ -130,7 +130,7 @@ Repos * `has_issues`: bool * `has_wiki`: bool * `has_downloads`: bool - * `team_id`: `int` + * `team_id` * `get_repo( name )`: `Repository` * `name`: string * `get_repos( [type] )`: list of `Repository` @@ -735,7 +735,7 @@ Repos * `has_issues`: bool * `has_wiki`: bool * `has_downloads`: bool - * `team_id`: `int` + * `team_id` * `get_repo( name )`: `Repository` * `name`: string * `get_repos( [type] )`: list of `Repository` @@ -754,10 +754,10 @@ Class `Plan` Attributes ---------- -* `collaborators` -* `name` -* `private_repos` -* `space` +* `collaborators`: integer +* `name`: string +* `private_repos`: integer +* `space`: integer Class `PullRequest` =================== diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index 9ad1b4a2..c34ff171 100644 --- a/github/GithubObjects/AuthenticatedUser.py +++ b/github/GithubObjects/AuthenticatedUser.py @@ -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" ] diff --git a/github/GithubObjects/Branch.py b/github/GithubObjects/Branch.py index dfb7c983..be8e60dc 100644 --- a/github/GithubObjects/Branch.py +++ b/github/GithubObjects/Branch.py @@ -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" ] diff --git a/github/GithubObjects/Commit.py b/github/GithubObjects/Commit.py index e9c0b4be..1203464e 100644 --- a/github/GithubObjects/Commit.py +++ b/github/GithubObjects/Commit.py @@ -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" ] diff --git a/github/GithubObjects/CommitComment.py b/github/GithubObjects/CommitComment.py index c84939e8..924890d9 100644 --- a/github/GithubObjects/CommitComment.py +++ b/github/GithubObjects/CommitComment.py @@ -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 ) diff --git a/github/GithubObjects/Event.py b/github/GithubObjects/Event.py index b945db3a..07040616 100644 --- a/github/GithubObjects/Event.py +++ b/github/GithubObjects/Event.py @@ -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" ] diff --git a/github/GithubObjects/Gist.py b/github/GithubObjects/Gist.py index 69c9a560..8819f148 100644 --- a/github/GithubObjects/Gist.py +++ b/github/GithubObjects/Gist.py @@ -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 ) diff --git a/github/GithubObjects/GistComment.py b/github/GithubObjects/GistComment.py index 9c57ba3b..44e02f22 100644 --- a/github/GithubObjects/GistComment.py +++ b/github/GithubObjects/GistComment.py @@ -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 ) diff --git a/github/GithubObjects/GitCommit.py b/github/GithubObjects/GitCommit.py index f1583ed8..efa7acf3 100644 --- a/github/GithubObjects/GitCommit.py +++ b/github/GithubObjects/GitCommit.py @@ -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" ] diff --git a/github/GithubObjects/GitRef.py b/github/GithubObjects/GitRef.py index ccd6da25..a2f3b19c 100644 --- a/github/GithubObjects/GitRef.py +++ b/github/GithubObjects/GitRef.py @@ -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" ] diff --git a/github/GithubObjects/Issue.py b/github/GithubObjects/Issue.py index a6844f4f..d8a5d911 100644 --- a/github/GithubObjects/Issue.py +++ b/github/GithubObjects/Issue.py @@ -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 ) diff --git a/github/GithubObjects/IssueComment.py b/github/GithubObjects/IssueComment.py index 2dec3f45..b5ea2f47 100644 --- a/github/GithubObjects/IssueComment.py +++ b/github/GithubObjects/IssueComment.py @@ -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 ) diff --git a/github/GithubObjects/IssueEvent.py b/github/GithubObjects/IssueEvent.py index 47f4d567..33f4e7c7 100644 --- a/github/GithubObjects/IssueEvent.py +++ b/github/GithubObjects/IssueEvent.py @@ -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" ] diff --git a/github/GithubObjects/Milestone.py b/github/GithubObjects/Milestone.py index 4c324a0d..5a82cbbb 100644 --- a/github/GithubObjects/Milestone.py +++ b/github/GithubObjects/Milestone.py @@ -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" ] diff --git a/github/GithubObjects/NamedUser.py b/github/GithubObjects/NamedUser.py index 7306b875..4c71f849 100644 --- a/github/GithubObjects/NamedUser.py +++ b/github/GithubObjects/NamedUser.py @@ -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" ] diff --git a/github/GithubObjects/Organization.py b/github/GithubObjects/Organization.py index 78b613bb..f83ff5ad 100644 --- a/github/GithubObjects/Organization.py +++ b/github/GithubObjects/Organization.py @@ -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" ] diff --git a/github/GithubObjects/Plan.py b/github/GithubObjects/Plan.py index 96837cd3..296de191 100644 --- a/github/GithubObjects/Plan.py +++ b/github/GithubObjects/Plan.py @@ -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" ] diff --git a/github/GithubObjects/PullRequest.py b/github/GithubObjects/PullRequest.py index 88dc8d94..9ecb0a24 100644 --- a/github/GithubObjects/PullRequest.py +++ b/github/GithubObjects/PullRequest.py @@ -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 ) diff --git a/github/GithubObjects/PullRequestComment.py b/github/GithubObjects/PullRequestComment.py index 558de5a9..1ddd18fe 100644 --- a/github/GithubObjects/PullRequestComment.py +++ b/github/GithubObjects/PullRequestComment.py @@ -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 ) diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 9c64902a..a6b47485 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -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" ] diff --git a/github/GithubObjects/Tag.py b/github/GithubObjects/Tag.py index 236ab861..d3193d13 100644 --- a/github/GithubObjects/Tag.py +++ b/github/GithubObjects/Tag.py @@ -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" ]