Switch to using six (#1189)

With the Python 2.7 deadline fast approaching, modernize the codebase
making use of the modernize module to switch to using six, as well as
other upcoming features, such as absolute imports . Stop using 2to3
for Travis, yay!
This commit is contained in:
Steve Kowalik
2019-08-05 14:06:19 +10:00
committed by GitHub
parent f1ae7200ba
commit dc2f2ad8cb
182 changed files with 850 additions and 629 deletions
-1
View File
@@ -10,7 +10,6 @@ matrix:
install: install:
- pip install codecov - pip install codecov
script: script:
- if [[ $TRAVIS_PYTHON_VERSION != '2.7' ]]; then python -m lib2to3 -w -n tests; fi
- coverage run --source github/tests setup.py test - coverage run --source github/tests setup.py test
after_success: after_success:
- codecov - codecov
+45 -43
View File
@@ -40,6 +40,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import datetime import datetime
import github.GithubObject import github.GithubObject
@@ -57,7 +58,8 @@ import github.Authorization
import github.Notification import github.Notification
import github.Migration import github.Migration
import Consts from . import Consts
import six
class AuthenticatedUser(github.GithubObject.CompletableGithubObject): class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
@@ -372,7 +374,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param email: string :param email: string
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (str, unicode)) for element in emails), emails assert all(isinstance(element, (str, six.text_type)) for element in emails), emails
post_parameters = emails post_parameters = emails
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"POST", "POST",
@@ -440,12 +442,12 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param onetime_password: string :param onetime_password: string
:rtype: :class:`github.Authorization.Authorization` :rtype: :class:`github.Authorization.Authorization`
""" """
assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in scopes), scopes assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in scopes), scopes
assert note is github.GithubObject.NotSet or isinstance(note, (str, unicode)), note assert note is github.GithubObject.NotSet or isinstance(note, (str, six.text_type)), note
assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, unicode)), note_url assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, six.text_type)), note_url
assert client_id is github.GithubObject.NotSet or isinstance(client_id, (str, unicode)), client_id assert client_id is github.GithubObject.NotSet or isinstance(client_id, (str, six.text_type)), client_id
assert client_secret is github.GithubObject.NotSet or isinstance(client_secret, (str, unicode)), client_secret assert client_secret is github.GithubObject.NotSet or isinstance(client_secret, (str, six.text_type)), client_secret
assert onetime_password is None or isinstance(onetime_password, (str, unicode)), onetime_password assert onetime_password is None or isinstance(onetime_password, (str, six.text_type)), onetime_password
post_parameters = dict() post_parameters = dict()
if scopes is not github.GithubObject.NotSet: if scopes is not github.GithubObject.NotSet:
post_parameters["scopes"] = scopes post_parameters["scopes"] = scopes
@@ -491,11 +493,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.Gist.Gist` :rtype: :class:`github.Gist.Gist`
""" """
assert isinstance(public, bool), public assert isinstance(public, bool), public
assert all(isinstance(element, github.InputFileContent) for element in files.itervalues()), files assert all(isinstance(element, github.InputFileContent) for element in six.itervalues(files)), files
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
post_parameters = { post_parameters = {
"public": public, "public": public,
"files": {key: value._identity for key, value in files.iteritems()}, "files": {key: value._identity for key, value in six.iteritems(files)},
} }
if description is not github.GithubObject.NotSet: if description is not github.GithubObject.NotSet:
post_parameters["description"] = description post_parameters["description"] = description
@@ -513,8 +515,8 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param key: string :param key: string
:rtype: :class:`github.UserKey.UserKey` :rtype: :class:`github.UserKey.UserKey`
""" """
assert isinstance(title, (str, unicode)), title assert isinstance(title, (str, six.text_type)), title
assert isinstance(key, (str, unicode)), key assert isinstance(key, (str, six.text_type)), key
post_parameters = { post_parameters = {
"title": title, "title": title,
"key": key, "key": key,
@@ -550,17 +552,17 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param allow_rebase_merge: bool :param allow_rebase_merge: bool
:rtype: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, six.text_type)), homepage
assert private is github.GithubObject.NotSet or isinstance(private, bool), private assert private is github.GithubObject.NotSet or isinstance(private, bool), private
assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues
assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki
assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads
assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects
assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init
assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, unicode)), license_template assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, six.text_type)), license_template
assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, unicode)), gitignore_template assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, six.text_type)), gitignore_template
assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge
assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit
assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge
@@ -612,13 +614,13 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param bio: string :param bio: string
:rtype: None :rtype: None
""" """
assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), name assert name is github.GithubObject.NotSet or isinstance(name, (str, six.text_type)), name
assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email assert email is github.GithubObject.NotSet or isinstance(email, (str, six.text_type)), email
assert blog is github.GithubObject.NotSet or isinstance(blog, (str, unicode)), blog assert blog is github.GithubObject.NotSet or isinstance(blog, (str, six.text_type)), blog
assert company is github.GithubObject.NotSet or isinstance(company, (str, unicode)), company assert company is github.GithubObject.NotSet or isinstance(company, (str, six.text_type)), company
assert location is github.GithubObject.NotSet or isinstance(location, (str, unicode)), location assert location is github.GithubObject.NotSet or isinstance(location, (str, six.text_type)), location
assert hireable is github.GithubObject.NotSet or isinstance(hireable, bool), hireable assert hireable is github.GithubObject.NotSet or isinstance(hireable, bool), hireable
assert bio is github.GithubObject.NotSet or isinstance(bio, (str, unicode)), bio assert bio is github.GithubObject.NotSet or isinstance(bio, (str, six.text_type)), bio
post_parameters = dict() post_parameters = dict()
if name is not github.GithubObject.NotSet: if name is not github.GithubObject.NotSet:
post_parameters["name"] = name post_parameters["name"] = name
@@ -647,7 +649,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.Authorization.Authorization` :rtype: :class:`github.Authorization.Authorization`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/authorizations/" + str(id) "/authorizations/" + str(id)
@@ -742,11 +744,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param since: datetime.datetime :param since: datetime.datetime
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue`
""" """
assert filter is github.GithubObject.NotSet or isinstance(filter, (str, unicode)), filter assert filter is github.GithubObject.NotSet or isinstance(filter, (str, six.text_type)), filter
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
url_parameters = dict() url_parameters = dict()
if filter is not github.GithubObject.NotSet: if filter is not github.GithubObject.NotSet:
@@ -780,11 +782,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param since: datetime.datetime :param since: datetime.datetime
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue`
""" """
assert filter is github.GithubObject.NotSet or isinstance(filter, (str, unicode)), filter assert filter is github.GithubObject.NotSet or isinstance(filter, (str, six.text_type)), filter
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
url_parameters = dict() url_parameters = dict()
if filter is not github.GithubObject.NotSet: if filter is not github.GithubObject.NotSet:
@@ -812,7 +814,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.UserKey.UserKey` :rtype: :class:`github.UserKey.UserKey`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/user/keys/" + str(id) "/user/keys/" + str(id)
@@ -837,7 +839,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.Notification.Notification` :rtype: :class:`github.Notification.Notification`
""" """
assert isinstance(id, (str, unicode)), id assert isinstance(id, (str, six.text_type)), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/notifications/threads/" + id "/notifications/threads/" + id
@@ -908,7 +910,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param name: string :param name: string
:rtype: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/repos/" + self.login + "/" + name "/repos/" + self.login + "/" + name
@@ -925,11 +927,11 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param direction: string :param direction: string
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
""" """
assert visibility is github.GithubObject.NotSet or isinstance(visibility, (str, unicode)), visibility assert visibility is github.GithubObject.NotSet or isinstance(visibility, (str, six.text_type)), visibility
assert affiliation is github.GithubObject.NotSet or isinstance(affiliation, (str, unicode)), affiliation assert affiliation is github.GithubObject.NotSet or isinstance(affiliation, (str, six.text_type)), affiliation
assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type assert type is github.GithubObject.NotSet or isinstance(type, (str, six.text_type)), type
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
url_parameters = dict() url_parameters = dict()
if visibility is not github.GithubObject.NotSet: if visibility is not github.GithubObject.NotSet:
url_parameters["visibility"] = visibility url_parameters["visibility"] = visibility
@@ -1082,7 +1084,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:param email: string :param email: string
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (str, unicode)) for element in emails), emails assert all(isinstance(element, (str, six.text_type)) for element in emails), emails
post_parameters = emails post_parameters = emails
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
@@ -1176,7 +1178,7 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.Migration.Migration` :rtype: :class:`github.Migration.Migration`
""" """
assert isinstance(repos, (list, tuple)), repos assert isinstance(repos, (list, tuple)), repos
assert all(isinstance(repo, (str, unicode)) for repo in repos), repos assert all(isinstance(repo, (str, six.text_type)) for repo in repos), repos
assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories
assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments
post_parameters = { post_parameters = {
+7 -5
View File
@@ -30,9 +30,11 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.AuthorizationApplication import github.AuthorizationApplication
import six
class Authorization(github.GithubObject.CompletableGithubObject): class Authorization(github.GithubObject.CompletableGithubObject):
@@ -135,11 +137,11 @@ class Authorization(github.GithubObject.CompletableGithubObject):
:param note_url: string :param note_url: string
:rtype: None :rtype: None
""" """
assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in scopes), scopes assert scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in scopes), scopes
assert add_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_scopes), add_scopes assert add_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in add_scopes), add_scopes
assert remove_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_scopes), remove_scopes assert remove_scopes is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in remove_scopes), remove_scopes
assert note is github.GithubObject.NotSet or isinstance(note, (str, unicode)), note assert note is github.GithubObject.NotSet or isinstance(note, (str, six.text_type)), note
assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, unicode)), note_url assert note_url is github.GithubObject.NotSet or isinstance(note_url, (str, six.text_type)), note_url
post_parameters = dict() post_parameters = dict()
if scopes is not github.GithubObject.NotSet: if scopes is not github.GithubObject.NotSet:
post_parameters["scopes"] = scopes post_parameters["scopes"] = scopes
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+11 -9
View File
@@ -33,6 +33,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.BranchProtection import github.BranchProtection
@@ -40,7 +41,8 @@ import github.Commit
import github.RequiredPullRequestReviews import github.RequiredPullRequestReviews
import github.RequiredStatusChecks import github.RequiredStatusChecks
import Consts from . import Consts
import six
class Branch(github.GithubObject.NonCompletableGithubObject): class Branch(github.GithubObject.NonCompletableGithubObject):
@@ -125,10 +127,10 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
changing. Use edit_required_status_checks() to avoid this. changing. Use edit_required_status_checks() to avoid this.
""" """
assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict
assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in contexts), contexts assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in contexts), contexts
assert enforce_admins is github.GithubObject.NotSet or isinstance(enforce_admins, bool), enforce_admins assert enforce_admins is github.GithubObject.NotSet or isinstance(enforce_admins, bool), enforce_admins
assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_users), dismissal_users assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_users), dismissal_users
assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_teams), dismissal_teams assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_teams), dismissal_teams
assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance(dismiss_stale_reviews, bool), dismiss_stale_reviews assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance(dismiss_stale_reviews, bool), dismiss_stale_reviews
assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance(require_code_owner_reviews, bool), require_code_owner_reviews assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance(require_code_owner_reviews, bool), require_code_owner_reviews
assert required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int), required_approving_review_count assert required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int), required_approving_review_count
@@ -207,7 +209,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
:contexts: list of strings :contexts: list of strings
""" """
assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict
assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in contexts), contexts assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in contexts), contexts
post_parameters = {} post_parameters = {}
if strict is not github.GithubObject.NotSet: if strict is not github.GithubObject.NotSet:
@@ -250,8 +252,8 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
:require_code_owner_reviews: bool :require_code_owner_reviews: bool
:required_approving_review_count: int :required_approving_review_count: int
""" """
assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_users), dismissal_users assert dismissal_users is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_users), dismissal_users
assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in dismissal_teams), dismissal_teams assert dismissal_teams is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in dismissal_teams), dismissal_teams
assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance(dismiss_stale_reviews, bool), dismiss_stale_reviews assert dismiss_stale_reviews is github.GithubObject.NotSet or isinstance(dismiss_stale_reviews, bool), dismiss_stale_reviews
assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance(require_code_owner_reviews, bool), require_code_owner_reviews assert require_code_owner_reviews is github.GithubObject.NotSet or isinstance(require_code_owner_reviews, bool), require_code_owner_reviews
assert required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int), required_approving_review_count assert required_approving_review_count is github.GithubObject.NotSet or isinstance(required_approving_review_count, int), required_approving_review_count
@@ -343,7 +345,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
:calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions <https://developer.github.com/v3/repos/branches>`_ :calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions <https://developer.github.com/v3/repos/branches>`_
:users: list of strings :users: list of strings
""" """
assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in users), users assert all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in users), users
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"POST", "POST",
@@ -356,7 +358,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
:calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions <https://developer.github.com/v3/repos/branches>`_ :calls: `POST /repos/:owner/:repo/branches/:branch/protection/restrictions <https://developer.github.com/v3/repos/branches>`_
:teams: list of strings :teams: list of strings
""" """
assert all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in teams), teams assert all(isinstance(element, (str, six.text_type)) or isinstance(element, (str, six.text_type)) for element in teams), teams
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"POST", "POST",
+1
View File
@@ -22,6 +22,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+10 -8
View File
@@ -32,6 +32,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
@@ -42,6 +43,7 @@ import github.CommitCombinedStatus
import github.File import github.File
import github.CommitStats import github.CommitStats
import github.CommitComment import github.CommitComment
import six
class Commit(github.GithubObject.CompletableGithubObject): class Commit(github.GithubObject.CompletableGithubObject):
@@ -141,10 +143,10 @@ class Commit(github.GithubObject.CompletableGithubObject):
:param position: integer :param position: integer
:rtype: :class:`github.CommitComment.CommitComment` :rtype: :class:`github.CommitComment.CommitComment`
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
assert line is github.GithubObject.NotSet or isinstance(line, (int, long)), line assert line is github.GithubObject.NotSet or isinstance(line, six.integer_types), line
assert path is github.GithubObject.NotSet or isinstance(path, (str, unicode)), path assert path is github.GithubObject.NotSet or isinstance(path, (str, six.text_type)), path
assert position is github.GithubObject.NotSet or isinstance(position, (int, long)), position assert position is github.GithubObject.NotSet or isinstance(position, six.integer_types), position
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
@@ -170,10 +172,10 @@ class Commit(github.GithubObject.CompletableGithubObject):
:param context: string :param context: string
:rtype: :class:`github.CommitStatus.CommitStatus` :rtype: :class:`github.CommitStatus.CommitStatus`
""" """
assert isinstance(state, (str, unicode)), state assert isinstance(state, (str, six.text_type)), state
assert target_url is github.GithubObject.NotSet or isinstance(target_url, (str, unicode)), target_url assert target_url is github.GithubObject.NotSet or isinstance(target_url, (str, six.text_type)), target_url
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert context is github.GithubObject.NotSet or isinstance(context, (str, unicode)), context assert context is github.GithubObject.NotSet or isinstance(context, (str, six.text_type)), context
post_parameters = { post_parameters = {
"state": state, "state": state,
} }
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.CommitStatus import github.CommitStatus
+5 -3
View File
@@ -32,10 +32,12 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
import Consts from . import Consts
import six
class CommitComment(github.GithubObject.CompletableGithubObject): class CommitComment(github.GithubObject.CompletableGithubObject):
@@ -150,7 +152,7 @@ class CommitComment(github.GithubObject.CompletableGithubObject):
:param body: string :param body: string
:rtype: None :rtype: None
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
@@ -182,7 +184,7 @@ class CommitComment(github.GithubObject.CompletableGithubObject):
:param reaction_type: string :param reaction_type: string
:rtype: :class:`github.Reaction.Reaction` :rtype: :class:`github.Reaction.Reaction`
""" """
assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string"
assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \
"Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)"
+1
View File
@@ -29,6 +29,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -32,6 +32,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
+1
View File
@@ -29,6 +29,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Commit import github.Commit
+1
View File
@@ -31,6 +31,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import base64 import base64
import sys import sys
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Organization import github.Organization
+1
View File
@@ -32,6 +32,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+7 -5
View File
@@ -33,6 +33,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
@@ -40,6 +41,7 @@ import github.GistComment
import github.NamedUser import github.NamedUser
import github.GistFile import github.GistFile
import github.GistHistoryState import github.GistHistoryState
import six
class Gist(github.GithubObject.CompletableGithubObject): class Gist(github.GithubObject.CompletableGithubObject):
@@ -208,7 +210,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
:param body: string :param body: string
:rtype: :class:`github.GistComment.GistComment` :rtype: :class:`github.GistComment.GistComment`
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
@@ -247,13 +249,13 @@ class Gist(github.GithubObject.CompletableGithubObject):
:param files: dict of string to :class:`github.InputFileContent.InputFileContent` :param files: dict of string to :class:`github.InputFileContent.InputFileContent`
:rtype: None :rtype: None
""" """
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert files is github.GithubObject.NotSet or all(element is None or isinstance(element, github.InputFileContent) for element in files.itervalues()), files assert files is github.GithubObject.NotSet or all(element is None or isinstance(element, github.InputFileContent) for element in six.itervalues(files)), files
post_parameters = dict() post_parameters = dict()
if description is not github.GithubObject.NotSet: if description is not github.GithubObject.NotSet:
post_parameters["description"] = description post_parameters["description"] = description
if files is not github.GithubObject.NotSet: if files is not github.GithubObject.NotSet:
post_parameters["files"] = {key: None if value is None else value._identity for key, value in files.iteritems()} post_parameters["files"] = {key: None if value is None else value._identity for key, value in six.iteritems(files)}
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"PATCH", "PATCH",
self.url, self.url,
@@ -267,7 +269,7 @@ class Gist(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.GistComment.GistComment` :rtype: :class:`github.GistComment.GistComment`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/comments/" + str(id) self.url + "/comments/" + str(id)
+3 -1
View File
@@ -30,9 +30,11 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
import six
class GistComment(github.GithubObject.CompletableGithubObject): class GistComment(github.GithubObject.CompletableGithubObject):
@@ -107,7 +109,7 @@ class GistComment(github.GithubObject.CompletableGithubObject):
:param body: string :param body: string
:rtype: None :rtype: None
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -29,6 +29,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.GitAuthor import github.GitAuthor
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+3 -1
View File
@@ -30,9 +30,11 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.GitObject import github.GitObject
import six
class GitRef(github.GithubObject.CompletableGithubObject): class GitRef(github.GithubObject.CompletableGithubObject):
@@ -84,7 +86,7 @@ class GitRef(github.GithubObject.CompletableGithubObject):
:param force: bool :param force: bool
:rtype: None :rtype: None
""" """
assert isinstance(sha, (str, unicode)), sha assert isinstance(sha, (str, six.text_type)), sha
assert force is github.GithubObject.NotSet or isinstance(force, bool), force assert force is github.GithubObject.NotSet or isinstance(force, bool), force
post_parameters = { post_parameters = {
"sha": sha, "sha": sha,
+9 -7
View File
@@ -35,10 +35,12 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
from os.path import basename from os.path import basename
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
import github.GitReleaseAsset import github.GitReleaseAsset
import six
class GitRelease(github.GithubObject.CompletableGithubObject): class GitRelease(github.GithubObject.CompletableGithubObject):
@@ -187,13 +189,13 @@ class GitRelease(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.GitRelease.GitRelease` :rtype: :class:`github.GitRelease.GitRelease`
""" """
assert tag_name is github.GithubObject.NotSet \ assert tag_name is github.GithubObject.NotSet \
or isinstance(tag_name, (str, unicode)), \ or isinstance(tag_name, (str, six.text_type)), \
'tag_name must be a str/unicode object' 'tag_name must be a str/unicode object'
assert target_commitish is github.GithubObject.NotSet \ assert target_commitish is github.GithubObject.NotSet \
or isinstance(target_commitish, (str, unicode)), \ or isinstance(target_commitish, (str, six.text_type)), \
'target_commitish must be a str/unicode object' 'target_commitish must be a str/unicode object'
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(message, (str, unicode)), message assert isinstance(message, (str, six.text_type)), message
assert isinstance(draft, bool), draft assert isinstance(draft, bool), draft
assert isinstance(prerelease, bool), prerelease assert isinstance(prerelease, bool), prerelease
if tag_name is github.GithubObject.NotSet: if tag_name is github.GithubObject.NotSet:
@@ -221,9 +223,9 @@ class GitRelease(github.GithubObject.CompletableGithubObject):
:calls: `POST https://<upload_url>/repos/:owner/:repo/releases/:release_id/assets <https://developer.github.com/v3/repos/releases/#upload-a-release-asset>`_ :calls: `POST https://<upload_url>/repos/:owner/:repo/releases/:release_id/assets <https://developer.github.com/v3/repos/releases/#upload-a-release-asset>`_
:rtype: :class:`github.GitReleaseAsset.GitReleaseAsset` :rtype: :class:`github.GitReleaseAsset.GitReleaseAsset`
""" """
assert isinstance(path, (str, unicode)), path assert isinstance(path, (str, six.text_type)), path
assert isinstance(label, (str, unicode)), label assert isinstance(label, (str, six.text_type)), label
assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), name assert name is github.GithubObject.NotSet or isinstance(name, (str, six.text_type)), name
post_parameters = { post_parameters = {
"label": label "label": label
+4 -2
View File
@@ -25,7 +25,9 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import six
class GitReleaseAsset(github.GithubObject.CompletableGithubObject): class GitReleaseAsset(github.GithubObject.CompletableGithubObject):
@@ -164,8 +166,8 @@ class GitReleaseAsset(github.GithubObject.CompletableGithubObject):
Update asset metadata. Update asset metadata.
:rtype: github.GitReleaseAsset.GitReleaseAsset :rtype: github.GitReleaseAsset.GitReleaseAsset
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(label, (str, unicode)), label assert isinstance(label, (str, six.text_type)), label
post_parameters = { post_parameters = {
"name": name, "name": name,
"label": label "label": label
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.GitAuthor import github.GitAuthor
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.GitTreeElement import github.GitTreeElement
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+15 -13
View File
@@ -32,12 +32,14 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import sys import sys
import datetime import datetime
from operator import itemgetter from operator import itemgetter
import GithubException from . import GithubException
import Consts from . import Consts
import six
atLeastPython3 = sys.hexversion >= 0x03000000 atLeastPython3 = sys.hexversion >= 0x03000000
@@ -140,18 +142,18 @@ class GithubObject(object):
elif isinstance(value, type): elif isinstance(value, type):
try: try:
return _ValuedAttribute(transform(value)) return _ValuedAttribute(transform(value))
except Exception, e: except Exception as e:
return _BadAttribute(value, type, e) return _BadAttribute(value, type, e)
else: else:
return _BadAttribute(value, type) return _BadAttribute(value, type)
@staticmethod @staticmethod
def _makeStringAttribute(value): def _makeStringAttribute(value):
return GithubObject.__makeSimpleAttribute(value, (str, unicode)) return GithubObject.__makeSimpleAttribute(value, (str, six.text_type))
@staticmethod @staticmethod
def _makeIntAttribute(value): def _makeIntAttribute(value):
return GithubObject.__makeSimpleAttribute(value, (int, long)) return GithubObject.__makeSimpleAttribute(value, six.integer_types)
@staticmethod @staticmethod
def _makeBoolAttribute(value): def _makeBoolAttribute(value):
@@ -163,7 +165,7 @@ class GithubObject(object):
@staticmethod @staticmethod
def _makeTimestampAttribute(value): def _makeTimestampAttribute(value):
return GithubObject.__makeTransformedAttribute(value, (int, long), datetime.datetime.utcfromtimestamp) return GithubObject.__makeTransformedAttribute(value, six.integer_types, datetime.datetime.utcfromtimestamp)
@staticmethod @staticmethod
def _makeDatetimeAttribute(value): def _makeDatetimeAttribute(value):
@@ -177,14 +179,14 @@ class GithubObject(object):
else: else:
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ") return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ")
return GithubObject.__makeTransformedAttribute(value, (str, unicode), parseDatetime) return GithubObject.__makeTransformedAttribute(value, (str, six.text_type), parseDatetime)
def _makeClassAttribute(self, klass, value): def _makeClassAttribute(self, klass, value):
return GithubObject.__makeTransformedAttribute(value, dict, lambda value: klass(self._requester, self._headers, value, completed=False)) return GithubObject.__makeTransformedAttribute(value, dict, lambda value: klass(self._requester, self._headers, value, completed=False))
@staticmethod @staticmethod
def _makeListOfStringsAttribute(value): def _makeListOfStringsAttribute(value):
return GithubObject.__makeSimpleListAttribute(value, (str, unicode)) return GithubObject.__makeSimpleListAttribute(value, (str, six.text_type))
@staticmethod @staticmethod
def _makeListOfIntsAttribute(value): def _makeListOfIntsAttribute(value):
@@ -205,10 +207,10 @@ class GithubObject(object):
return _BadAttribute(value, [dict]) return _BadAttribute(value, [dict])
def _makeDictOfStringsToClassesAttribute(self, klass, value): def _makeDictOfStringsToClassesAttribute(self, klass, value):
if isinstance(value, dict) and all(isinstance(key, (str, unicode)) and isinstance(element, dict) for key, element in value.iteritems()): if isinstance(value, dict) and all(isinstance(key, (str, six.text_type)) and isinstance(element, dict) for key, element in six.iteritems(value)):
return _ValuedAttribute(dict((key, klass(self._requester, self._headers, element, completed=False)) for key, element in value.iteritems())) return _ValuedAttribute(dict((key, klass(self._requester, self._headers, element, completed=False)) for key, element in six.iteritems(value)))
else: else:
return _BadAttribute(value, {(str, unicode): dict}) return _BadAttribute(value, {(str, six.text_type): dict})
@property @property
def etag(self): def etag(self):
@@ -230,11 +232,11 @@ class GithubObject(object):
""" """
def format_params(params): def format_params(params):
if atLeastPython3: if atLeastPython3:
items = params.items() items = list(params.items())
else: else:
items = list(params.items()) items = list(params.items())
for k, v in sorted(items, key=itemgetter(0), reverse=True): for k, v in sorted(items, key=itemgetter(0), reverse=True):
isText = isinstance(v, (str, unicode)) isText = isinstance(v, (str, six.text_type))
if isText and not atLeastPython3: if isText and not atLeastPython3:
v = v.encode('utf-8') v = v.encode('utf-8')
yield '{k}="{v}"'.format(k=k, v=v) if isText else '{k}={v}'.format(k=k, v=v) yield '{k}="{v}"'.format(k=k, v=v) if isText else '{k}={v}'.format(k=k, v=v)
+1
View File
@@ -29,6 +29,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+6 -4
View File
@@ -31,9 +31,11 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.HookResponse import github.HookResponse
import six
class Hook(github.GithubObject.CompletableGithubObject): class Hook(github.GithubObject.CompletableGithubObject):
@@ -153,11 +155,11 @@ class Hook(github.GithubObject.CompletableGithubObject):
:param active: bool :param active: bool
:rtype: None :rtype: None
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(config, dict), config assert isinstance(config, dict), config
assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events
assert add_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in add_events), add_events assert add_events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in add_events), add_events
assert remove_events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in remove_events), remove_events assert remove_events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in remove_events), remove_events
assert active is github.GithubObject.NotSet or isinstance(active, bool), active assert active is github.GithubObject.NotSet or isinstance(active, bool), active
post_parameters = { post_parameters = {
"name": name, "name": name,
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+4 -2
View File
@@ -28,7 +28,9 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import six
class InputFileContent(object): class InputFileContent(object):
@@ -42,8 +44,8 @@ class InputFileContent(object):
:param new_name: string :param new_name: string
""" """
assert isinstance(content, (str, unicode)), content assert isinstance(content, (str, six.text_type)), content
assert new_name is github.GithubObject.NotSet or isinstance(new_name, (str, unicode)), new_name assert new_name is github.GithubObject.NotSet or isinstance(new_name, (str, six.text_type)), new_name
self.__newName = new_name self.__newName = new_name
self.__content = content self.__content = content
+5 -3
View File
@@ -30,7 +30,9 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import six
class InputGitAuthor(object): class InputGitAuthor(object):
@@ -45,9 +47,9 @@ class InputGitAuthor(object):
:param date: string :param date: string
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(email, (str, unicode)), email assert isinstance(email, (str, six.text_type)), email
assert date is github.GithubObject.NotSet or isinstance(date, (str, unicode)), date # @todo Datetime? assert date is github.GithubObject.NotSet or isinstance(date, (str, six.text_type)), date # @todo Datetime?
self.__name = name self.__name = name
self.__email = email self.__email = email
+7 -5
View File
@@ -28,7 +28,9 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import six
class InputGitTreeElement(object): class InputGitTreeElement(object):
@@ -45,11 +47,11 @@ class InputGitTreeElement(object):
:param sha: string :param sha: string
""" """
assert isinstance(path, (str, unicode)), path assert isinstance(path, (str, six.text_type)), path
assert isinstance(mode, (str, unicode)), mode assert isinstance(mode, (str, six.text_type)), mode
assert isinstance(type, (str, unicode)), type assert isinstance(type, (str, six.text_type)), type
assert content is github.GithubObject.NotSet or isinstance(content, (str, unicode)), content assert content is github.GithubObject.NotSet or isinstance(content, (str, six.text_type)), content
assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), sha assert sha is github.GithubObject.NotSet or isinstance(sha, (str, six.text_type)), sha
self.__path = path self.__path = path
self.__mode = mode self.__mode = mode
self.__type = type self.__type = type
+2 -1
View File
@@ -25,6 +25,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
@@ -39,7 +40,7 @@ import github.Event
import github.Authorization import github.Authorization
import github.Notification import github.Notification
import Consts from . import Consts
INTEGRATION_PREVIEW_HEADERS = {"Accept": Consts.mediaTypeIntegrationPreview} INTEGRATION_PREVIEW_HEADERS = {"Accept": Consts.mediaTypeIntegrationPreview}
+1
View File
@@ -25,6 +25,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
import github.NamedUser import github.NamedUser
+1
View File
@@ -24,6 +24,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+21 -19
View File
@@ -42,7 +42,8 @@
# # # #
################################################################################ ################################################################################
import urllib from __future__ import absolute_import
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import datetime import datetime
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
@@ -56,7 +57,8 @@ import github.IssueComment
import github.IssuePullRequest import github.IssuePullRequest
import github.Reaction import github.Reaction
import Consts from . import Consts
import six
class Issue(github.GithubObject.CompletableGithubObject): class Issue(github.GithubObject.CompletableGithubObject):
@@ -280,7 +282,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param assignee: :class:`github.NamedUser.NamedUser` or string :param assignee: :class:`github.NamedUser.NamedUser` or string
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (github.NamedUser.NamedUser, str, unicode)) for element in assignees), assignees assert all(isinstance(element, (github.NamedUser.NamedUser, str, six.text_type)) for element in assignees), assignees
post_parameters = {"assignees": [assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees]} post_parameters = {"assignees": [assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees]}
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"POST", "POST",
@@ -295,7 +297,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param label: :class:`github.Label.Label` or string :param label: :class:`github.Label.Label` or string
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels
post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels]
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"POST", "POST",
@@ -309,7 +311,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param body: string :param body: string
:rtype: :class:`github.IssueComment.IssueComment` :rtype: :class:`github.IssueComment.IssueComment`
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
@@ -342,20 +344,20 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param labels: list of string :param labels: list of string
:rtype: None :rtype: None
""" """
assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title assert title is github.GithubObject.NotSet or isinstance(title, (str, six.text_type)), title
assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body
assert assignee is github.GithubObject.NotSet or assignee is None or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee assert assignee is github.GithubObject.NotSet or assignee is None or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee
assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, unicode)) for element in assignees), assignees assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, six.text_type)) for element in assignees), assignees
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert milestone is github.GithubObject.NotSet or milestone is None or isinstance(milestone, github.Milestone.Milestone), milestone assert milestone is github.GithubObject.NotSet or milestone is None or isinstance(milestone, github.Milestone.Milestone), milestone
assert labels is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in labels), labels assert labels is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in labels), labels
post_parameters = dict() post_parameters = dict()
if title is not github.GithubObject.NotSet: if title is not github.GithubObject.NotSet:
post_parameters["title"] = title post_parameters["title"] = title
if body is not github.GithubObject.NotSet: if body is not github.GithubObject.NotSet:
post_parameters["body"] = body post_parameters["body"] = body
if assignee is not github.GithubObject.NotSet: if assignee is not github.GithubObject.NotSet:
if isinstance(assignee, (str, unicode)): if isinstance(assignee, (str, six.text_type)):
post_parameters["assignee"] = assignee post_parameters["assignee"] = assignee
else: else:
post_parameters["assignee"] = assignee._identity if assignee else '' post_parameters["assignee"] = assignee._identity if assignee else ''
@@ -380,7 +382,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param lock_reason: string :param lock_reason: string
:rtype: None :rtype: None
""" """
assert isinstance(lock_reason, (str, unicode)), lock_reason assert isinstance(lock_reason, (str, six.text_type)), lock_reason
put_parameters = dict() put_parameters = dict()
put_parameters["lock_reason"] = lock_reason put_parameters["lock_reason"] = lock_reason
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
@@ -406,7 +408,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.IssueComment.IssueComment` :rtype: :class:`github.IssueComment.IssueComment`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self._parentUrl(self.url) + "/comments/" + str(id) self._parentUrl(self.url) + "/comments/" + str(id)
@@ -461,7 +463,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param assignee: :class:`github.NamedUser.NamedUser` or string :param assignee: :class:`github.NamedUser.NamedUser` or string
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (github.NamedUser.NamedUser, str, unicode)) for element in assignees), assignees assert all(isinstance(element, (github.NamedUser.NamedUser, str, six.text_type)) for element in assignees), assignees
post_parameters = {"assignees": [assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees]} post_parameters = {"assignees": [assignee.login if isinstance(assignee, github.NamedUser.NamedUser) else assignee for assignee in assignees]}
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
@@ -476,11 +478,11 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param label: :class:`github.Label.Label` or string :param label: :class:`github.Label.Label` or string
:rtype: None :rtype: None
""" """
assert isinstance(label, (github.Label.Label, str, unicode)), label assert isinstance(label, (github.Label.Label, str, six.text_type)), label
if isinstance(label, github.Label.Label): if isinstance(label, github.Label.Label):
label = label._identity label = label._identity
else: else:
label = urllib.quote(label) label = six.moves.urllib.parse.quote(label)
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
self.url + "/labels/" + label self.url + "/labels/" + label
@@ -492,7 +494,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param labels: list of :class:`github.Label.Label` or strings :param labels: list of :class:`github.Label.Label` or strings
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels
post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels]
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"PUT", "PUT",
@@ -519,7 +521,7 @@ class Issue(github.GithubObject.CompletableGithubObject):
:param reaction_type: string :param reaction_type: string
:rtype: :class:`github.Reaction.Reaction` :rtype: :class:`github.Reaction.Reaction`
""" """
assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string"
assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \
"Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)"
+5 -3
View File
@@ -33,10 +33,12 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
import Consts from . import Consts
import six
class IssueComment(github.GithubObject.CompletableGithubObject): class IssueComment(github.GithubObject.CompletableGithubObject):
@@ -127,7 +129,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
:param body: string :param body: string
:rtype: None :rtype: None
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
@@ -159,7 +161,7 @@ class IssueComment(github.GithubObject.CompletableGithubObject):
:param reaction_type: string :param reaction_type: string
:rtype: :class:`github.Reaction.Reaction` :rtype: :class:`github.Reaction.Reaction`
""" """
assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string"
assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \
"Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)"
+1
View File
@@ -31,6 +31,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Issue import github.Issue
+1
View File
@@ -29,6 +29,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+8 -6
View File
@@ -31,11 +31,13 @@
# # # #
################################################################################ ################################################################################
import urllib from __future__ import absolute_import
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import github.GithubObject import github.GithubObject
import Consts from . import Consts
import six
class Label(github.GithubObject.CompletableGithubObject): class Label(github.GithubObject.CompletableGithubObject):
@@ -96,9 +98,9 @@ class Label(github.GithubObject.CompletableGithubObject):
:param description: string :param description: string
:rtype: None :rtype: None
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(color, (str, unicode)), color assert isinstance(color, (str, six.text_type)), color
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
post_parameters = { post_parameters = {
"name": name, "name": name,
"color": color, "color": color,
@@ -115,7 +117,7 @@ class Label(github.GithubObject.CompletableGithubObject):
@property @property
def _identity(self): def _identity(self):
return urllib.quote(self.name) return six.moves.urllib.parse.quote(self.name)
def _initAttributes(self): def _initAttributes(self):
self._color = github.GithubObject.NotSet self._color = github.GithubObject.NotSet
+5 -3
View File
@@ -29,9 +29,11 @@
# # # #
################################################################################ ################################################################################
import urlparse from __future__ import absolute_import
import six.moves.urllib.parse
import github.PaginatedList import github.PaginatedList
import six
class PaginatedList(github.PaginatedList.PaginatedListBase): class PaginatedList(github.PaginatedList.PaginatedListBase):
@@ -55,7 +57,7 @@ class PaginatedList(github.PaginatedList.PaginatedListBase):
return self.get_page(page) return self.get_page(page)
def get_page(self, page): def get_page(self, page):
assert isinstance(page, (int, long)), page assert isinstance(page, six.integer_types), page
args = dict(self.__args) args = dict(self.__args)
if page != 0: if page != 0:
args["start_page"] = page + 1 args["start_page"] = page + 1
@@ -133,7 +135,7 @@ def convertRepo(attributes):
def convertIssue(attributes): def convertIssue(attributes):
convertedAttributes = { convertedAttributes = {
"number": attributes["number"], "number": attributes["number"],
"url": "/repos" + urlparse.urlparse(attributes["html_url"]).path, "url": "/repos" + six.moves.urllib.parse.urlparse(attributes["html_url"]).path,
"user": {"login": attributes["user"], "url": "/users/" + attributes["user"]}, "user": {"login": attributes["user"], "url": "/users/" + attributes["user"]},
} }
if "labels" in attributes: # pragma no branch if "labels" in attributes: # pragma no branch
+1
View File
@@ -22,6 +22,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
+44 -42
View File
@@ -48,6 +48,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import datetime import datetime
import pickle import pickle
@@ -57,24 +58,25 @@ import requests
import jwt import jwt
import urllib3 import urllib3
from Requester import Requester from .Requester import Requester
import AuthenticatedUser from . import AuthenticatedUser
import NamedUser from . import NamedUser
import Gist from . import Gist
import github.PaginatedList import github.PaginatedList
import Repository from . import Repository
import Installation from . import Installation
import License from . import License
import Topic from . import Topic
import github.GithubObject import github.GithubObject
import HookDescription from . import HookDescription
import GitignoreTemplate from . import GitignoreTemplate
import RateLimit from . import RateLimit
import InstallationAuthorization from . import InstallationAuthorization
import GithubException from . import GithubException
import Invitation from . import Invitation
import Consts from . import Consts
import six
atLeastPython3 = sys.hexversion >= 0x03000000 atLeastPython3 = sys.hexversion >= 0x03000000
@@ -106,14 +108,14 @@ class Github(object):
:param retry: int or urllib3.util.retry.Retry object :param retry: int or urllib3.util.retry.Retry object
""" """
assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token assert login_or_token is None or isinstance(login_or_token, (str, six.text_type)), login_or_token
assert password is None or isinstance(password, (str, unicode)), password assert password is None or isinstance(password, (str, six.text_type)), password
assert jwt is None or isinstance(jwt, (str, unicode)), jwt assert jwt is None or isinstance(jwt, (str, six.text_type)), jwt
assert isinstance(base_url, (str, unicode)), base_url assert isinstance(base_url, (str, six.text_type)), base_url
assert isinstance(timeout, (int, long)), timeout assert isinstance(timeout, six.integer_types), timeout
assert client_id is None or isinstance(client_id, (str, unicode)), client_id assert client_id is None or isinstance(client_id, (str, six.text_type)), client_id
assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret assert client_secret is None or isinstance(client_secret, (str, six.text_type)), client_secret
assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent assert user_agent is None or isinstance(user_agent, (str, six.text_type)), user_agent
assert isinstance(api_preview, (bool)) assert isinstance(api_preview, (bool))
assert retry is None or isinstance(retry, (int)) or isinstance(retry, (urllib3.util.Retry)) assert retry is None or isinstance(retry, (int)) or isinstance(retry, (urllib3.util.Retry))
self.__requester = Requester(login_or_token, password, jwt, base_url, timeout, client_id, client_secret, user_agent, per_page, api_preview, verify, retry) self.__requester = Requester(login_or_token, password, jwt, base_url, timeout, client_id, client_secret, user_agent, per_page, api_preview, verify, retry)
@@ -194,7 +196,7 @@ class Github(object):
:rtype: :class:`github.License.License` :rtype: :class:`github.License.License`
""" """
assert isinstance(key, (str, unicode)), key assert isinstance(key, (str, six.text_type)), key
headers, data = self.__requester.requestJsonAndCheck( headers, data = self.__requester.requestJsonAndCheck(
"GET", "GET",
"/licenses/" + key "/licenses/" + key
@@ -222,7 +224,7 @@ class Github(object):
:param login: string :param login: string
:rtype: :class:`github.NamedUser.NamedUser` :rtype: :class:`github.NamedUser.NamedUser`
""" """
assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login assert login is github.GithubObject.NotSet or isinstance(login, (str, six.text_type)), login
if login is github.GithubObject.NotSet: if login is github.GithubObject.NotSet:
return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False) return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False)
else: else:
@@ -238,7 +240,7 @@ class Github(object):
:param since: integer :param since: integer
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
""" """
assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since assert since is github.GithubObject.NotSet or isinstance(since, six.integer_types), since
url_parameters = dict() url_parameters = dict()
if since is not github.GithubObject.NotSet: if since is not github.GithubObject.NotSet:
url_parameters["since"] = since url_parameters["since"] = since
@@ -255,7 +257,7 @@ class Github(object):
:param login: string :param login: string
:rtype: :class:`github.Organization.Organization` :rtype: :class:`github.Organization.Organization`
""" """
assert isinstance(login, (str, unicode)), login assert isinstance(login, (str, six.text_type)), login
headers, data = self.__requester.requestJsonAndCheck( headers, data = self.__requester.requestJsonAndCheck(
"GET", "GET",
"/orgs/" + login "/orgs/" + login
@@ -268,7 +270,7 @@ class Github(object):
:param since: integer :param since: integer
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization`
""" """
assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since assert since is github.GithubObject.NotSet or isinstance(since, six.integer_types), since
url_parameters = dict() url_parameters = dict()
if since is not github.GithubObject.NotSet: if since is not github.GithubObject.NotSet:
url_parameters["since"] = since url_parameters["since"] = since
@@ -284,8 +286,8 @@ class Github(object):
:calls: `GET /repos/:owner/:repo <http://developer.github.com/v3/repos>`_ or `GET /repositories/:id <http://developer.github.com/v3/repos>`_ :calls: `GET /repos/:owner/:repo <http://developer.github.com/v3/repos>`_ or `GET /repositories/:id <http://developer.github.com/v3/repos>`_
:rtype: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository`
""" """
assert isinstance(full_name_or_id, (str, unicode, int, long)), full_name_or_id assert isinstance(full_name_or_id, (str, six.text_type, int, int)), full_name_or_id
url_base = "/repositories/" if isinstance(full_name_or_id, int) or isinstance(full_name_or_id, long) else "/repos/" url_base = "/repositories/" if isinstance(full_name_or_id, int) or isinstance(full_name_or_id, int) else "/repos/"
url = "%s%s" % (url_base, full_name_or_id) url = "%s%s" % (url_base, full_name_or_id)
if lazy: if lazy:
return Repository.Repository(self.__requester, {}, {"url": url}, completed=False) return Repository.Repository(self.__requester, {}, {"url": url}, completed=False)
@@ -302,7 +304,7 @@ class Github(object):
:param visibility: string ('all','public') :param visibility: string ('all','public')
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
""" """
assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since assert since is github.GithubObject.NotSet or isinstance(since, six.integer_types), since
url_parameters = dict() url_parameters = dict()
if since is not github.GithubObject.NotSet: if since is not github.GithubObject.NotSet:
url_parameters["since"] = since url_parameters["since"] = since
@@ -335,7 +337,7 @@ class Github(object):
:param id: string :param id: string
:rtype: :class:`github.Gist.Gist` :rtype: :class:`github.Gist.Gist`
""" """
assert isinstance(id, (str, unicode)), id assert isinstance(id, (str, six.text_type)), id
headers, data = self.__requester.requestJsonAndCheck( headers, data = self.__requester.requestJsonAndCheck(
"GET", "GET",
"/gists/" + id "/gists/" + id
@@ -368,7 +370,7 @@ class Github(object):
:param qualifiers: keyword dict query qualifiers :param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
""" """
assert isinstance(query, (str, unicode)), query assert isinstance(query, (str, six.text_type)), query
url_parameters = dict() url_parameters = dict()
if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered)
assert sort in ('stars', 'forks', 'updated'), sort assert sort in ('stars', 'forks', 'updated'), sort
@@ -403,7 +405,7 @@ class Github(object):
:param qualifiers: keyword dict query qualifiers :param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
""" """
assert isinstance(query, (str, unicode)), query assert isinstance(query, (str, six.text_type)), query
url_parameters = dict() url_parameters = dict()
if sort is not github.GithubObject.NotSet: if sort is not github.GithubObject.NotSet:
assert sort in ('followers', 'repositories', 'joined'), sort assert sort in ('followers', 'repositories', 'joined'), sort
@@ -438,7 +440,7 @@ class Github(object):
:param qualifiers: keyword dict query qualifiers :param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue`
""" """
assert isinstance(query, (str, unicode)), query assert isinstance(query, (str, six.text_type)), query
url_parameters = dict() url_parameters = dict()
if sort is not github.GithubObject.NotSet: if sort is not github.GithubObject.NotSet:
assert sort in ('comments', 'created', 'updated'), sort assert sort in ('comments', 'created', 'updated'), sort
@@ -474,7 +476,7 @@ class Github(object):
:param qualifiers: keyword dict query qualifiers :param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ContentFile.ContentFile` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ContentFile.ContentFile`
""" """
assert isinstance(query, (str, unicode)), query assert isinstance(query, (str, six.text_type)), query
url_parameters = dict() url_parameters = dict()
if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered)
assert sort in ('indexed',), sort assert sort in ('indexed',), sort
@@ -512,7 +514,7 @@ class Github(object):
:param qualifiers: keyword dict query qualifiers :param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit`
""" """
assert isinstance(query, (str, unicode)), query assert isinstance(query, (str, six.text_type)), query
url_parameters = dict() url_parameters = dict()
if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered)
assert sort in ('author-date', 'committer-date'), sort assert sort in ('author-date', 'committer-date'), sort
@@ -548,7 +550,7 @@ class Github(object):
:param qualifiers: keyword dict query qualifiers :param qualifiers: keyword dict query qualifiers
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Topic.Topic` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Topic.Topic`
""" """
assert isinstance(query, (str, unicode)), query assert isinstance(query, (str, six.text_type)), query
url_parameters = dict() url_parameters = dict()
query_chunks = [] query_chunks = []
@@ -578,7 +580,7 @@ class Github(object):
:param context: :class:`github.Repository.Repository` :param context: :class:`github.Repository.Repository`
:rtype: string :rtype: string
""" """
assert isinstance(text, (str, unicode)), text assert isinstance(text, (str, six.text_type)), text
assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context
post_parameters = { post_parameters = {
"text": text "text": text
@@ -599,7 +601,7 @@ class Github(object):
:param name: string :param name: string
:rtype: :class:`github.HookDescription.HookDescription` :rtype: :class:`github.HookDescription.HookDescription`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
headers, attributes = self.__requester.requestJsonAndCheck( headers, attributes = self.__requester.requestJsonAndCheck(
"GET", "GET",
"/hooks/" + name "/hooks/" + name
@@ -633,7 +635,7 @@ class Github(object):
:calls: `GET /gitignore/templates/:name <http://developer.github.com/v3/gitignore>`_ :calls: `GET /gitignore/templates/:name <http://developer.github.com/v3/gitignore>`_
:rtype: :class:`github.GitignoreTemplate.GitignoreTemplate` :rtype: :class:`github.GitignoreTemplate.GitignoreTemplate`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
headers, attributes = self.__requester.requestJsonAndCheck( headers, attributes = self.__requester.requestJsonAndCheck(
"GET", "GET",
"/gitignore/templates/" + name "/gitignore/templates/" + name
@@ -707,7 +709,7 @@ class GithubIntegration(object):
self.base_url = base_url self.base_url = base_url
self.integration_id = integration_id self.integration_id = integration_id
self.private_key = private_key self.private_key = private_key
assert isinstance(base_url, (str, unicode)), base_url assert isinstance(base_url, (str, six.text_type)), base_url
def create_jwt(self, expiration=60): def create_jwt(self, expiration=60):
""" """
+4 -2
View File
@@ -32,12 +32,14 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
import github.NamedUser import github.NamedUser
import Consts from . import Consts
import six
class Migration(github.GithubObject.CompletableGithubObject): class Migration(github.GithubObject.CompletableGithubObject):
@@ -176,7 +178,7 @@ class Migration(github.GithubObject.CompletableGithubObject):
:param repo_name: str :param repo_name: str
:rtype: None :rtype: None
""" """
assert isinstance(repo_name, (str, unicode)), repo_name assert isinstance(repo_name, (str, six.text_type)), repo_name
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
self.url + "/repos/" + repo_name + "/lock", self.url + "/repos/" + repo_name + "/lock",
+5 -3
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import datetime import datetime
import github.GithubObject import github.GithubObject
@@ -37,6 +38,7 @@ import github.PaginatedList
import github.NamedUser import github.NamedUser
import github.Label import github.Label
import six
class Milestone(github.GithubObject.CompletableGithubObject): class Milestone(github.GithubObject.CompletableGithubObject):
@@ -170,9 +172,9 @@ class Milestone(github.GithubObject.CompletableGithubObject):
:param due_on: date :param due_on: date
:rtype: None :rtype: None
""" """
assert isinstance(title, (str, unicode)), title assert isinstance(title, (str, six.text_type)), title
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert due_on is github.GithubObject.NotSet or isinstance(due_on, datetime.date), due_on assert due_on is github.GithubObject.NotSet or isinstance(due_on, datetime.date), due_on
post_parameters = { post_parameters = {
"title": title, "title": title,
+6 -4
View File
@@ -37,6 +37,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import datetime import datetime
import github.GithubObject import github.GithubObject
@@ -49,6 +50,7 @@ import github.Permissions
import github.Plan import github.Plan
import github.Organization import github.Organization
import github.Event import github.Event
import six
class NamedUser(github.GithubObject.CompletableGithubObject): class NamedUser(github.GithubObject.CompletableGithubObject):
@@ -536,7 +538,7 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
:param name: string :param name: string
:rtype: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/repos/" + self.login + "/" + name "/repos/" + self.login + "/" + name
@@ -552,9 +554,9 @@ class NamedUser(github.GithubObject.CompletableGithubObject):
:param direction: string :param direction: string
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
""" """
assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type assert type is github.GithubObject.NotSet or isinstance(type, (str, six.text_type)), type
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
url_parameters = dict() url_parameters = dict()
if type is not github.GithubObject.NotSet: if type is not github.GithubObject.NotSet:
url_parameters["type"] = type url_parameters["type"] = type
+1
View File
@@ -29,6 +29,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Repository import github.Repository
+1
View File
@@ -28,6 +28,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+44 -42
View File
@@ -41,6 +41,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import datetime import datetime
import github.GithubObject import github.GithubObject
@@ -53,7 +54,8 @@ import github.Repository
import github.Project import github.Project
import github.NamedUser import github.NamedUser
import Consts from . import Consts
import six
class Organization(github.GithubObject.CompletableGithubObject): class Organization(github.GithubObject.CompletableGithubObject):
@@ -319,7 +321,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param role: string :param role: string
:rtype: None :rtype: None
""" """
assert role is github.GithubObject.NotSet or isinstance(role, (str, unicode)), role assert role is github.GithubObject.NotSet or isinstance(role, (str, six.text_type)), role
assert isinstance(member, github.NamedUser.NamedUser), member assert isinstance(member, github.NamedUser.NamedUser), member
put_parameters = {} put_parameters = {}
if role is not github.GithubObject.NotSet: if role is not github.GithubObject.NotSet:
@@ -367,9 +369,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param active: bool :param active: bool
:rtype: :class:`github.Hook.Hook` :rtype: :class:`github.Hook.Hook`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(config, dict), config assert isinstance(config, dict), config
assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events
assert active is github.GithubObject.NotSet or isinstance(active, bool), active assert active is github.GithubObject.NotSet or isinstance(active, bool), active
post_parameters = { post_parameters = {
"name": name, "name": name,
@@ -412,18 +414,18 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param allow_rebase_merge: bool :param allow_rebase_merge: bool
:rtype: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, six.text_type)), homepage
assert private is github.GithubObject.NotSet or isinstance(private, bool), private assert private is github.GithubObject.NotSet or isinstance(private, bool), private
assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues
assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki
assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads
assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects
assert team_id is github.GithubObject.NotSet or isinstance(team_id, (int, long)), team_id assert team_id is github.GithubObject.NotSet or isinstance(team_id, six.integer_types), team_id
assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init assert auto_init is github.GithubObject.NotSet or isinstance(auto_init, bool), auto_init
assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, unicode)), license_template assert license_template is github.GithubObject.NotSet or isinstance(license_template, (str, six.text_type)), license_template
assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, unicode)), gitignore_template assert gitignore_template is github.GithubObject.NotSet or isinstance(gitignore_template, (str, six.text_type)), gitignore_template
assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge
assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit
assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge
@@ -475,11 +477,11 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param description: string :param description: string
:rtype: :class:`github.Team.Team` :rtype: :class:`github.Team.Team`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert repo_names is github.GithubObject.NotSet or all(isinstance(element, github.Repository.Repository) for element in repo_names), repo_names assert repo_names is github.GithubObject.NotSet or all(isinstance(element, github.Repository.Repository) for element in repo_names), repo_names
assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission assert permission is github.GithubObject.NotSet or isinstance(permission, (str, six.text_type)), permission
assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, unicode)), privacy assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, six.text_type)), privacy
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
post_parameters = { post_parameters = {
"name": name, "name": name,
} }
@@ -504,7 +506,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: None` :rtype: None`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
self.url + "/hooks/" + str(id) self.url + "/hooks/" + str(id)
@@ -522,13 +524,13 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param name: string :param name: string
:rtype: None :rtype: None
""" """
assert billing_email is github.GithubObject.NotSet or isinstance(billing_email, (str, unicode)), billing_email assert billing_email is github.GithubObject.NotSet or isinstance(billing_email, (str, six.text_type)), billing_email
assert blog is github.GithubObject.NotSet or isinstance(blog, (str, unicode)), blog assert blog is github.GithubObject.NotSet or isinstance(blog, (str, six.text_type)), blog
assert company is github.GithubObject.NotSet or isinstance(company, (str, unicode)), company assert company is github.GithubObject.NotSet or isinstance(company, (str, six.text_type)), company
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email assert email is github.GithubObject.NotSet or isinstance(email, (str, six.text_type)), email
assert location is github.GithubObject.NotSet or isinstance(location, (str, unicode)), location assert location is github.GithubObject.NotSet or isinstance(location, (str, six.text_type)), location
assert name is github.GithubObject.NotSet or isinstance(name, (str, unicode)), name assert name is github.GithubObject.NotSet or isinstance(name, (str, six.text_type)), name
post_parameters = dict() post_parameters = dict()
if billing_email is not github.GithubObject.NotSet: if billing_email is not github.GithubObject.NotSet:
post_parameters["billing_email"] = billing_email post_parameters["billing_email"] = billing_email
@@ -561,10 +563,10 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param active: bool :param active: bool
:rtype: :class:`github.Hook.Hook` :rtype: :class:`github.Hook.Hook`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(config, dict), config assert isinstance(config, dict), config
assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events
assert active is github.GithubObject.NotSet or isinstance(active, bool), active assert active is github.GithubObject.NotSet or isinstance(active, bool), active
post_parameters = { post_parameters = {
"name": name, "name": name,
@@ -599,7 +601,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.Hook.Hook` :rtype: :class:`github.Hook.Hook`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/hooks/" + str(id) self.url + "/hooks/" + str(id)
@@ -630,11 +632,11 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param since: datetime.datetime :param since: datetime.datetime
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue`
""" """
assert filter is github.GithubObject.NotSet or isinstance(filter, (str, unicode)), filter assert filter is github.GithubObject.NotSet or isinstance(filter, (str, six.text_type)), filter
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
url_parameters = dict() url_parameters = dict()
if filter is not github.GithubObject.NotSet: if filter is not github.GithubObject.NotSet:
@@ -665,9 +667,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
""" """
assert (filter_ is github.GithubObject.NotSet or assert (filter_ is github.GithubObject.NotSet or
isinstance(filter_, (str, unicode))), filter_ isinstance(filter_, (str, six.text_type))), filter_
assert (role is github.GithubObject.NotSet or assert (role is github.GithubObject.NotSet or
isinstance(role, (str, unicode))), role isinstance(role, (str, six.text_type))), role
url_parameters = {} url_parameters = {}
if filter_ is not github.GithubObject.NotSet: if filter_ is not github.GithubObject.NotSet:
@@ -719,7 +721,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
""" """
assert (filter_ is github.GithubObject.NotSet or assert (filter_ is github.GithubObject.NotSet or
isinstance(filter_, (str, unicode))), filter_ isinstance(filter_, (str, six.text_type))), filter_
url_parameters = {} url_parameters = {}
if filter_ is not github.GithubObject.NotSet: if filter_ is not github.GithubObject.NotSet:
@@ -761,7 +763,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param name: string :param name: string
:rtype: :class:`github.Repository.Repository` :rtype: :class:`github.Repository.Repository`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/repos/" + self.login + "/" + name "/repos/" + self.login + "/" + name
@@ -776,9 +778,9 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param direction: string ('asc', desc') :param direction: string ('asc', desc')
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
""" """
assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type assert type is github.GithubObject.NotSet or isinstance(type, (str, six.text_type)), type
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
url_parameters = dict() url_parameters = dict()
if type is not github.GithubObject.NotSet: if type is not github.GithubObject.NotSet:
@@ -800,7 +802,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.Team.Team` :rtype: :class:`github.Team.Team`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/teams/" + str(id) "/teams/" + str(id)
@@ -813,7 +815,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:param slug: string :param slug: string
:rtype: :class:`github.Team.Team` :rtype: :class:`github.Team.Team`
""" """
assert isinstance(slug, (str, unicode)), slug assert isinstance(slug, (str, six.text_type)), slug
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/teams/" + slug self.url + "/teams/" + slug
@@ -857,7 +859,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:rtype: None :rtype: None
""" """
assert user is github.GithubObject.NotSet or isinstance(user, github.NamedUser.NamedUser), user assert user is github.GithubObject.NotSet or isinstance(user, github.NamedUser.NamedUser), user
assert email is github.GithubObject.NotSet or isinstance(email, (str, unicode)), email assert email is github.GithubObject.NotSet or isinstance(email, (str, six.text_type)), email
assert (email is github.GithubObject.NotSet) ^ (user is github.GithubObject.NotSet), "specify only one of email or user" assert (email is github.GithubObject.NotSet) ^ (user is github.GithubObject.NotSet), "specify only one of email or user"
parameters = {} parameters = {}
if user is not github.GithubObject.NotSet: if user is not github.GithubObject.NotSet:
@@ -865,7 +867,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
elif email is not github.GithubObject.NotSet: elif email is not github.GithubObject.NotSet:
parameters["email"] = email parameters["email"] = email
if role is not github.GithubObject.NotSet: if role is not github.GithubObject.NotSet:
assert isinstance(role, (str, unicode)), role assert isinstance(role, (str, six.text_type)), role
assert role in ['admin', 'direct_member', 'billing_manager'] assert role in ['admin', 'direct_member', 'billing_manager']
parameters["role"] = role parameters["role"] = role
if teams is not github.GithubObject.NotSet: if teams is not github.GithubObject.NotSet:
@@ -954,7 +956,7 @@ class Organization(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.Migration.Migration` :rtype: :class:`github.Migration.Migration`
""" """
assert isinstance(repos, (list, tuple)), repos assert isinstance(repos, (list, tuple)), repos
assert all(isinstance(repo, (str, unicode)) for repo in repos), repos assert all(isinstance(repo, (str, six.text_type)) for repo in repos), repos
assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories
assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments
post_parameters = { post_parameters = {
+4 -2
View File
@@ -1,3 +1,5 @@
from __future__ import absolute_import
import six
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################ Copyrights and license ############################ ############################ Copyrights and license ############################
@@ -40,7 +42,7 @@
try: try:
from urllib.parse import parse_qs from urllib.parse import parse_qs
except ImportError: except ImportError:
from urlparse import parse_qs from six.moves.urllib.parse import parse_qs
class PaginatedListBase: class PaginatedListBase:
@@ -49,7 +51,7 @@ class PaginatedListBase:
def __getitem__(self, index): def __getitem__(self, index):
assert isinstance(index, (int, slice)) assert isinstance(index, (int, slice))
if isinstance(index, (int, long)): if isinstance(index, six.integer_types):
self.__fetchToIndex(index) self.__fetchToIndex(index)
return self.__elements[index] return self.__elements[index]
else: else:
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+4 -2
View File
@@ -22,10 +22,12 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.ProjectColumn import github.ProjectColumn
import Consts from . import Consts
import six
class Project(github.GithubObject.CompletableGithubObject): class Project(github.GithubObject.CompletableGithubObject):
@@ -159,7 +161,7 @@ class Project(github.GithubObject.CompletableGithubObject):
calls: `POST https://developer.github.com/v3/projects/columns/#create-a-project-column>`_ calls: `POST https://developer.github.com/v3/projects/columns/#create-a-project-column>`_
:param name: string :param name: string
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
post_parameters = {"name": name} post_parameters = {"name": name}
import_header = {"Accept": Consts.mediaTypeProjectsPreview} import_header = {"Accept": Consts.mediaTypeProjectsPreview}
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
+1
View File
@@ -22,6 +22,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
# NOTE: There is currently no way to get cards "in triage" for a project. # NOTE: There is currently no way to get cards "in triage" for a project.
+6 -4
View File
@@ -22,11 +22,13 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Project import github.Project
import github.ProjectCard import github.ProjectCard
import Consts from . import Consts
import six
class ProjectColumn(github.GithubObject.CompletableGithubObject): class ProjectColumn(github.GithubObject.CompletableGithubObject):
@@ -99,7 +101,7 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectCard.ProjectCard` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ProjectCard.ProjectCard`
:param archived_state: string :param archived_state: string
""" """
assert archived_state is github.GithubObject.NotSet or isinstance(archived_state, (str, unicode)), archived_state assert archived_state is github.GithubObject.NotSet or isinstance(archived_state, (str, six.text_type)), archived_state
url_parameters = dict() url_parameters = dict()
if archived_state is not github.GithubObject.NotSet: if archived_state is not github.GithubObject.NotSet:
@@ -123,14 +125,14 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
:param content_type: string :param content_type: string
""" """
post_parameters = {} post_parameters = {}
if isinstance(note, (str, unicode)): if isinstance(note, (str, six.text_type)):
assert content_id is github.GithubObject.NotSet, content_id assert content_id is github.GithubObject.NotSet, content_id
assert content_type is github.GithubObject.NotSet, content_type assert content_type is github.GithubObject.NotSet, content_type
post_parameters = {"note": note} post_parameters = {"note": note}
else: else:
assert note is github.GithubObject.NotSet, note assert note is github.GithubObject.NotSet, note
assert isinstance(content_id, int), content_id assert isinstance(content_id, int), content_id
assert isinstance(content_type, (str, unicode)), content_type assert isinstance(content_type, (str, six.text_type)), content_type
post_parameters = {"content_id": content_id, post_parameters = {"content_id": content_id,
"content_type": content_type} "content_type": content_type}
+28 -26
View File
@@ -42,8 +42,9 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import datetime import datetime
import urllib import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
@@ -56,7 +57,8 @@ import github.IssueComment
import github.Commit import github.Commit
import github.PullRequestReview import github.PullRequestReview
import Consts from . import Consts
import six
class PullRequest(github.GithubObject.CompletableGithubObject): class PullRequest(github.GithubObject.CompletableGithubObject):
@@ -386,10 +388,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param position: integer :param position: integer
:rtype: :class:`github.PullRequestComment.PullRequestComment` :rtype: :class:`github.PullRequestComment.PullRequestComment`
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
assert isinstance(commit_id, github.Commit.Commit), commit_id assert isinstance(commit_id, github.Commit.Commit), commit_id
assert isinstance(path, (str, unicode)), path assert isinstance(path, (str, six.text_type)), path
assert isinstance(position, (int, long)), position assert isinstance(position, six.integer_types), position
post_parameters = { post_parameters = {
"body": body, "body": body,
"commit_id": commit_id._identity, "commit_id": commit_id._identity,
@@ -409,7 +411,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param body: string :param body: string
:rtype: :class:`github.IssueComment.IssueComment` :rtype: :class:`github.IssueComment.IssueComment`
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
@@ -459,10 +461,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
""" """
post_parameters = dict() post_parameters = dict()
if reviewers is not github.GithubObject.NotSet: if reviewers is not github.GithubObject.NotSet:
assert all(isinstance(element, (str, unicode)) for element in reviewers), reviewers assert all(isinstance(element, (str, six.text_type)) for element in reviewers), reviewers
post_parameters["reviewers"] = reviewers post_parameters["reviewers"] = reviewers
if team_reviewers is not github.GithubObject.NotSet: if team_reviewers is not github.GithubObject.NotSet:
assert all(isinstance(element, (str, unicode)) for element in team_reviewers), team_reviewers assert all(isinstance(element, (str, six.text_type)) for element in team_reviewers), team_reviewers
post_parameters["team_reviewers"] = team_reviewers post_parameters["team_reviewers"] = team_reviewers
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"POST", "POST",
@@ -479,10 +481,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
""" """
post_parameters = dict() post_parameters = dict()
if reviewers is not github.GithubObject.NotSet: if reviewers is not github.GithubObject.NotSet:
assert all(isinstance(element, (str, unicode)) for element in reviewers), reviewers assert all(isinstance(element, (str, six.text_type)) for element in reviewers), reviewers
post_parameters["reviewers"] = reviewers post_parameters["reviewers"] = reviewers
if team_reviewers is not github.GithubObject.NotSet: if team_reviewers is not github.GithubObject.NotSet:
assert all(isinstance(element, (str, unicode)) for element in team_reviewers), team_reviewers assert all(isinstance(element, (str, six.text_type)) for element in team_reviewers), team_reviewers
post_parameters["team_reviewers"] = team_reviewers post_parameters["team_reviewers"] = team_reviewers
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
@@ -499,10 +501,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param base: string :param base: string
:rtype: None :rtype: None
""" """
assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title assert title is github.GithubObject.NotSet or isinstance(title, (str, six.text_type)), title
assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert base is github.GithubObject.NotSet or isinstance(base, (str, unicode)), base assert base is github.GithubObject.NotSet or isinstance(base, (str, six.text_type)), base
post_parameters = dict() post_parameters = dict()
if title is not github.GithubObject.NotSet: if title is not github.GithubObject.NotSet:
post_parameters["title"] = title post_parameters["title"] = title
@@ -533,7 +535,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.PullRequestComment.PullRequestComment` :rtype: :class:`github.PullRequestComment.PullRequestComment`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self._parentUrl(self.url) + "/comments/" + str(id) self._parentUrl(self.url) + "/comments/" + str(id)
@@ -572,7 +574,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
return github.PaginatedList.PaginatedList( return github.PaginatedList.PaginatedList(
github.PullRequestComment.PullRequestComment, github.PullRequestComment.PullRequestComment,
self._requester, self._requester,
@@ -610,7 +612,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.IssueComment.IssueComment` :rtype: :class:`github.IssueComment.IssueComment`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self._parentUrl(self.issue_url) + "/comments/" + str(id) self._parentUrl(self.issue_url) + "/comments/" + str(id)
@@ -648,7 +650,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.PullRequestReview.PullRequestReview` :rtype: :class:`github.PullRequestReview.PullRequestReview`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/reviews/" + str(id), self.url + "/reviews/" + str(id),
@@ -707,7 +709,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param label: :class:`github.Label.Label` or string :param label: :class:`github.Label.Label` or string
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels
post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels]
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"POST", "POST",
@@ -731,11 +733,11 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param label: :class:`github.Label.Label` or string :param label: :class:`github.Label.Label` or string
:rtype: None :rtype: None
""" """
assert isinstance(label, (github.Label.Label, str, unicode)), label assert isinstance(label, (github.Label.Label, str, six.text_type)), label
if isinstance(label, github.Label.Label): if isinstance(label, github.Label.Label):
label = label._identity label = label._identity
else: else:
label = urllib.quote(label) label = six.moves.urllib.parse.quote(label)
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
self.issue_url + "/labels/" + label self.issue_url + "/labels/" + label
@@ -747,7 +749,7 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param labels: list of :class:`github.Label.Label` or strings :param labels: list of :class:`github.Label.Label` or strings
:rtype: None :rtype: None
""" """
assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels assert all(isinstance(element, (github.Label.Label, str, six.text_type)) for element in labels), labels
post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels] post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels]
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"PUT", "PUT",
@@ -772,10 +774,10 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
:param commit_message: string :param commit_message: string
:rtype: :class:`github.PullRequestMergeStatus.PullRequestMergeStatus` :rtype: :class:`github.PullRequestMergeStatus.PullRequestMergeStatus`
""" """
assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, unicode)), commit_message assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, six.text_type)), commit_message
assert commit_title is github.GithubObject.NotSet or isinstance(commit_title, (str, unicode)), commit_title assert commit_title is github.GithubObject.NotSet or isinstance(commit_title, (str, six.text_type)), commit_title
assert merge_method is github.GithubObject.NotSet or isinstance(merge_method, (str, unicode)), merge_method assert merge_method is github.GithubObject.NotSet or isinstance(merge_method, (str, six.text_type)), merge_method
assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), sha assert sha is github.GithubObject.NotSet or isinstance(sha, (str, six.text_type)), sha
post_parameters = dict() post_parameters = dict()
if commit_message is not github.GithubObject.NotSet: if commit_message is not github.GithubObject.NotSet:
post_parameters["commit_message"] = commit_message post_parameters["commit_message"] = commit_message
+5 -3
View File
@@ -34,10 +34,12 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
import Consts from . import Consts
import six
class PullRequestComment(github.GithubObject.CompletableGithubObject): class PullRequestComment(github.GithubObject.CompletableGithubObject):
@@ -184,7 +186,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
:param body: string :param body: string
:rtype: None :rtype: None
""" """
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"body": body, "body": body,
} }
@@ -216,7 +218,7 @@ class PullRequestComment(github.GithubObject.CompletableGithubObject):
:param reaction_type: string :param reaction_type: string
:rtype: :class:`github.Reaction.Reaction` :rtype: :class:`github.Reaction.Reaction`
""" """
assert isinstance(reaction_type, (str, unicode)), "reaction type should be a string" assert isinstance(reaction_type, (str, six.text_type)), "reaction type should be a string"
assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \ assert reaction_type in ["+1", "-1", "laugh", "confused", "heart", "hooray"], \
"Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)" "Invalid reaction type (https://developer.github.com/v3/reactions/#reaction-types)"
+1
View File
@@ -31,6 +31,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -30,6 +30,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Repository import github.Repository
+3 -1
View File
@@ -26,9 +26,11 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
import six
class PullRequestReview(github.GithubObject.CompletableGithubObject): class PullRequestReview(github.GithubObject.CompletableGithubObject):
@@ -116,7 +118,7 @@ class PullRequestReview(github.GithubObject.CompletableGithubObject):
:calls: `PUT /repos/:owner/:repo/pulls/:number/reviews/:review_id/dismissals <https://developer.github.com/v3/pulls/reviews/>`_ :calls: `PUT /repos/:owner/:repo/pulls/:number/reviews/:review_id/dismissals <https://developer.github.com/v3/pulls/reviews/>`_
:rtype: None :rtype: None
""" """
assert isinstance(message, (str, unicode)), message assert isinstance(message, (str, six.text_type)), message
post_parameters = {'message': message} post_parameters = {'message': message}
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"PUT", "PUT",
+1
View File
@@ -27,6 +27,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -27,6 +27,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Rate import github.Rate
+2 -1
View File
@@ -24,10 +24,11 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
import Consts from . import Consts
class Reaction(github.GithubObject.CompletableGithubObject): class Reaction(github.GithubObject.CompletableGithubObject):
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+137 -135
View File
@@ -85,8 +85,9 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import sys import sys
import urllib import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import datetime import datetime
from base64 import b64encode from base64 import b64encode
@@ -134,7 +135,8 @@ import github.Path
import github.Clones import github.Clones
import github.View import github.View
import Consts from . import Consts
import six
atLeastPython3 = sys.hexversion >= 0x03000000 atLeastPython3 = sys.hexversion >= 0x03000000
@@ -778,8 +780,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param permission: string 'pull', 'push' or 'admin' :param permission: string 'pull', 'push' or 'admin'
:rtype: None :rtype: None
""" """
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator
assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission assert permission is github.GithubObject.NotSet or isinstance(permission, (str, six.text_type)), permission
if isinstance(collaborator, github.NamedUser.NamedUser): if isinstance(collaborator, github.NamedUser.NamedUser):
collaborator = collaborator._identity collaborator = collaborator._identity
@@ -805,7 +807,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param collaborator: string or :class:`github.NamedUser.NamedUser` :param collaborator: string or :class:`github.NamedUser.NamedUser`
:rtype: string :rtype: string
""" """
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator
if isinstance(collaborator, github.NamedUser.NamedUser): if isinstance(collaborator, github.NamedUser.NamedUser):
collaborator = collaborator._identity collaborator = collaborator._identity
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
@@ -845,8 +847,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param head: string :param head: string
:rtype: :class:`github.Comparison.Comparison` :rtype: :class:`github.Comparison.Comparison`
""" """
assert isinstance(base, (str, unicode)), base assert isinstance(base, (str, six.text_type)), base
assert isinstance(head, (str, unicode)), head assert isinstance(head, (str, six.text_type)), head
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/compare/" + base + "..." + head self.url + "/compare/" + base + "..." + head
@@ -860,8 +862,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param encoding: string :param encoding: string
:rtype: :class:`github.GitBlob.GitBlob` :rtype: :class:`github.GitBlob.GitBlob`
""" """
assert isinstance(content, (str, unicode)), content assert isinstance(content, (str, six.text_type)), content
assert isinstance(encoding, (str, unicode)), encoding assert isinstance(encoding, (str, six.text_type)), encoding
post_parameters = { post_parameters = {
"content": content, "content": content,
"encoding": encoding, "encoding": encoding,
@@ -883,7 +885,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param committer: :class:`github.InputGitAuthor.InputGitAuthor` :param committer: :class:`github.InputGitAuthor.InputGitAuthor`
:rtype: :class:`github.GitCommit.GitCommit` :rtype: :class:`github.GitCommit.GitCommit`
""" """
assert isinstance(message, (str, unicode)), message assert isinstance(message, (str, six.text_type)), message
assert isinstance(tree, github.GitTree.GitTree), tree assert isinstance(tree, github.GitTree.GitTree), tree
assert all(isinstance(element, github.GitCommit.GitCommit) for element in parents), parents assert all(isinstance(element, github.GitCommit.GitCommit) for element in parents), parents
assert author is github.GithubObject.NotSet or isinstance(author, github.InputGitAuthor), author assert author is github.GithubObject.NotSet or isinstance(author, github.InputGitAuthor), author
@@ -911,8 +913,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param sha: string :param sha: string
:rtype: :class:`github.GitRef.GitRef` :rtype: :class:`github.GitRef.GitRef`
""" """
assert isinstance(ref, (str, unicode)), ref assert isinstance(ref, (str, six.text_type)), ref
assert isinstance(sha, (str, unicode)), sha assert isinstance(sha, (str, six.text_type)), sha
post_parameters = { post_parameters = {
"ref": ref, "ref": ref,
"sha": sha, "sha": sha,
@@ -939,12 +941,12 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param target_commitish: string or :class:`github.Branch.Branch` or :class:`github.Commit.Commit` or :class:`github.GitCommit.GitCommit` :param target_commitish: string or :class:`github.Branch.Branch` or :class:`github.Commit.Commit` or :class:`github.GitCommit.GitCommit`
:rtype: :class:`github.GitRelease.GitRelease` :rtype: :class:`github.GitRelease.GitRelease`
""" """
assert isinstance(tag, (str, unicode)), tag assert isinstance(tag, (str, six.text_type)), tag
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(message, (str, unicode)), message assert isinstance(message, (str, six.text_type)), message
assert isinstance(draft, bool), draft assert isinstance(draft, bool), draft
assert isinstance(prerelease, bool), prerelease assert isinstance(prerelease, bool), prerelease
assert target_commitish is github.GithubObject.NotSet or isinstance(target_commitish, (str, unicode, github.Branch.Branch, github.Commit.Commit, github.GitCommit.GitCommit)), target_commitish assert target_commitish is github.GithubObject.NotSet or isinstance(target_commitish, (str, six.text_type, github.Branch.Branch, github.Commit.Commit, github.GitCommit.GitCommit)), target_commitish
post_parameters = { post_parameters = {
"tag_name": tag, "tag_name": tag,
"name": name, "name": name,
@@ -952,7 +954,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
"draft": draft, "draft": draft,
"prerelease": prerelease, "prerelease": prerelease,
} }
if isinstance(target_commitish, (str, unicode)): if isinstance(target_commitish, (str, six.text_type)):
post_parameters["target_commitish"] = target_commitish post_parameters["target_commitish"] = target_commitish
elif isinstance(target_commitish, github.Branch.Branch): elif isinstance(target_commitish, github.Branch.Branch):
post_parameters["target_commitish"] = target_commitish.name post_parameters["target_commitish"] = target_commitish.name
@@ -975,10 +977,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param tagger: :class:`github.InputGitAuthor.InputGitAuthor` :param tagger: :class:`github.InputGitAuthor.InputGitAuthor`
:rtype: :class:`github.GitTag.GitTag` :rtype: :class:`github.GitTag.GitTag`
""" """
assert isinstance(tag, (str, unicode)), tag assert isinstance(tag, (str, six.text_type)), tag
assert isinstance(message, (str, unicode)), message assert isinstance(message, (str, six.text_type)), message
assert isinstance(object, (str, unicode)), object assert isinstance(object, (str, six.text_type)), object
assert isinstance(type, (str, unicode)), type assert isinstance(type, (str, six.text_type)), type
assert tagger is github.GithubObject.NotSet or isinstance(tagger, github.InputGitAuthor), tagger assert tagger is github.GithubObject.NotSet or isinstance(tagger, github.InputGitAuthor), tagger
post_parameters = { post_parameters = {
"tag": tag, "tag": tag,
@@ -1025,9 +1027,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param active: bool :param active: bool
:rtype: :class:`github.Hook.Hook` :rtype: :class:`github.Hook.Hook`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(config, dict), config assert isinstance(config, dict), config
assert events is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) for element in events), events assert events is github.GithubObject.NotSet or all(isinstance(element, (str, six.text_type)) for element in events), events
assert active is github.GithubObject.NotSet or isinstance(active, bool), active assert active is github.GithubObject.NotSet or isinstance(active, bool), active
post_parameters = { post_parameters = {
"name": name, "name": name,
@@ -1055,12 +1057,12 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param labels: list of :class:`github.Label.Label` :param labels: list of :class:`github.Label.Label`
:rtype: :class:`github.Issue.Issue` :rtype: :class:`github.Issue.Issue`
""" """
assert isinstance(title, (str, unicode)), title assert isinstance(title, (str, six.text_type)), title
assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body
assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee
assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, unicode)) for element in assignees), assignees assert assignees is github.GithubObject.NotSet or all(isinstance(element, github.NamedUser.NamedUser) or isinstance(element, (str, six.text_type)) for element in assignees), assignees
assert milestone is github.GithubObject.NotSet or isinstance(milestone, github.Milestone.Milestone), milestone assert milestone is github.GithubObject.NotSet or isinstance(milestone, github.Milestone.Milestone), milestone
assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) or isinstance(element, (str, unicode)) for element in labels), labels assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) or isinstance(element, (str, six.text_type)) for element in labels), labels
post_parameters = { post_parameters = {
"title": title, "title": title,
@@ -1068,7 +1070,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
if body is not github.GithubObject.NotSet: if body is not github.GithubObject.NotSet:
post_parameters["body"] = body post_parameters["body"] = body
if assignee is not github.GithubObject.NotSet: if assignee is not github.GithubObject.NotSet:
if isinstance(assignee, (str, unicode)): if isinstance(assignee, (str, six.text_type)):
post_parameters["assignee"] = assignee post_parameters["assignee"] = assignee
else: else:
post_parameters["assignee"] = assignee._identity post_parameters["assignee"] = assignee._identity
@@ -1093,8 +1095,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param read_only: bool :param read_only: bool
:rtype: :class:`github.RepositoryKey.RepositoryKey` :rtype: :class:`github.RepositoryKey.RepositoryKey`
""" """
assert isinstance(title, (str, unicode)), title assert isinstance(title, (str, six.text_type)), title
assert isinstance(key, (str, unicode)), key assert isinstance(key, (str, six.text_type)), key
assert isinstance(read_only, bool), read_only assert isinstance(read_only, bool), read_only
post_parameters = { post_parameters = {
"title": title, "title": title,
@@ -1116,9 +1118,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param description: string :param description: string
:rtype: :class:`github.Label.Label` :rtype: :class:`github.Label.Label`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert isinstance(color, (str, unicode)), color assert isinstance(color, (str, six.text_type)), color
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
post_parameters = { post_parameters = {
"name": name, "name": name,
"color": color, "color": color,
@@ -1142,9 +1144,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param due_on: datetime :param due_on: datetime
:rtype: :class:`github.Milestone.Milestone` :rtype: :class:`github.Milestone.Milestone`
""" """
assert isinstance(title, (str, unicode)), title assert isinstance(title, (str, six.text_type)), title
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert due_on is github.GithubObject.NotSet or isinstance(due_on, (datetime.datetime, datetime.date)), due_on assert due_on is github.GithubObject.NotSet or isinstance(due_on, (datetime.datetime, datetime.date)), due_on
post_parameters = { post_parameters = {
"title": title, "title": title,
@@ -1171,8 +1173,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param name: string :param name: string
:param body: string :param body: string
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert body is github.GithubObject.NotSet or isinstance(body, (str, unicode)), body assert body is github.GithubObject.NotSet or isinstance(body, (str, six.text_type)), body
post_parameters = { post_parameters = {
"name": name, "name": name,
"body": body, "body": body,
@@ -1205,10 +1207,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
return self.__create_pull_2(*args, **kwds) return self.__create_pull_2(*args, **kwds)
def __create_pull_1(self, title, body, base, head, maintainer_can_modify=github.GithubObject.NotSet): def __create_pull_1(self, title, body, base, head, maintainer_can_modify=github.GithubObject.NotSet):
assert isinstance(title, (str, unicode)), title assert isinstance(title, (str, six.text_type)), title
assert isinstance(body, (str, unicode)), body assert isinstance(body, (str, six.text_type)), body
assert isinstance(base, (str, unicode)), base assert isinstance(base, (str, six.text_type)), base
assert isinstance(head, (str, unicode)), head assert isinstance(head, (str, six.text_type)), head
assert maintainer_can_modify is github.GithubObject.NotSet or isinstance(maintainer_can_modify, bool), maintainer_can_modify assert maintainer_can_modify is github.GithubObject.NotSet or isinstance(maintainer_can_modify, bool), maintainer_can_modify
if maintainer_can_modify is not github.GithubObject.NotSet: if maintainer_can_modify is not github.GithubObject.NotSet:
return self.__create_pull(title=title, body=body, base=base, head=head, maintainer_can_modify=maintainer_can_modify) return self.__create_pull(title=title, body=body, base=base, head=head, maintainer_can_modify=maintainer_can_modify)
@@ -1217,8 +1219,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
def __create_pull_2(self, issue, base, head): def __create_pull_2(self, issue, base, head):
assert isinstance(issue, github.Issue.Issue), issue assert isinstance(issue, github.Issue.Issue), issue
assert isinstance(base, (str, unicode)), base assert isinstance(base, (str, six.text_type)), base
assert isinstance(head, (str, unicode)), head assert isinstance(head, (str, six.text_type)), head
return self.__create_pull(issue=issue._identity, base=base, head=head) return self.__create_pull(issue=issue._identity, base=base, head=head)
def __create_pull(self, **kwds): def __create_pull(self, **kwds):
@@ -1239,10 +1241,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param vcs_password: string :param vcs_password: string
:rtype: :class:`github.SourceImport.SourceImport` :rtype: :class:`github.SourceImport.SourceImport`
""" """
assert isinstance(vcs, (str, unicode)), vcs assert isinstance(vcs, (str, six.text_type)), vcs
assert isinstance(vcs_url, (str, unicode)), vcs_url assert isinstance(vcs_url, (str, six.text_type)), vcs_url
assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, (str, unicode)), vcs_username assert vcs_username is github.GithubObject.NotSet or isinstance(vcs_username, (str, six.text_type)), vcs_username
assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, (str, unicode)), vcs_password assert vcs_password is github.GithubObject.NotSet or isinstance(vcs_password, (str, six.text_type)), vcs_password
put_parameters = { put_parameters = {
"vcs": vcs, "vcs": vcs,
"vcs_url": vcs_url "vcs_url": vcs_url
@@ -1295,15 +1297,15 @@ class Repository(github.GithubObject.CompletableGithubObject):
""" """
if name is None: if name is None:
name = self.name name = self.name
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, unicode)), homepage assert homepage is github.GithubObject.NotSet or isinstance(homepage, (str, six.text_type)), homepage
assert private is github.GithubObject.NotSet or isinstance(private, bool), private assert private is github.GithubObject.NotSet or isinstance(private, bool), private
assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues assert has_issues is github.GithubObject.NotSet or isinstance(has_issues, bool), has_issues
assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects assert has_projects is github.GithubObject.NotSet or isinstance(has_projects, bool), has_projects
assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki assert has_wiki is github.GithubObject.NotSet or isinstance(has_wiki, bool), has_wiki
assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads assert has_downloads is github.GithubObject.NotSet or isinstance(has_downloads, bool), has_downloads
assert default_branch is github.GithubObject.NotSet or isinstance(default_branch, (str, unicode)), default_branch assert default_branch is github.GithubObject.NotSet or isinstance(default_branch, (str, six.text_type)), default_branch
assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge assert allow_squash_merge is github.GithubObject.NotSet or isinstance(allow_squash_merge, bool), allow_squash_merge
assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit assert allow_merge_commit is github.GithubObject.NotSet or isinstance(allow_merge_commit, bool), allow_merge_commit
assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge assert allow_rebase_merge is github.GithubObject.NotSet or isinstance(allow_rebase_merge, bool), allow_rebase_merge
@@ -1349,8 +1351,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param ref: string :param ref: string
:rtype: string :rtype: string
""" """
assert isinstance(archive_format, (str, unicode)), archive_format assert isinstance(archive_format, (str, six.text_type)), archive_format
assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref
url = self.url + "/" + archive_format url = self.url + "/" + archive_format
if ref is not github.GithubObject.NotSet: if ref is not github.GithubObject.NotSet:
url += "/" + ref url += "/" + ref
@@ -1378,7 +1380,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param branch: string :param branch: string
:rtype: :class:`github.Branch.Branch` :rtype: :class:`github.Branch.Branch`
""" """
assert isinstance(branch, (str, unicode)), branch assert isinstance(branch, (str, six.text_type)), branch
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/branches/" + branch self.url + "/branches/" + branch
@@ -1425,7 +1427,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.CommitComment.CommitComment` :rtype: :class:`github.CommitComment.CommitComment`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/comments/" + str(id) self.url + "/comments/" + str(id)
@@ -1450,7 +1452,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param sha: string :param sha: string
:rtype: :class:`github.Commit.Commit` :rtype: :class:`github.Commit.Commit`
""" """
assert isinstance(sha, (str, unicode)), sha assert isinstance(sha, (str, six.text_type)), sha
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/commits/" + sha self.url + "/commits/" + sha
@@ -1467,11 +1469,11 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param author: string or :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser` :param author: string or :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser`
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit`
""" """
assert sha is github.GithubObject.NotSet or isinstance(sha, (str, unicode)), sha assert sha is github.GithubObject.NotSet or isinstance(sha, (str, six.text_type)), sha
assert path is github.GithubObject.NotSet or isinstance(path, (str, unicode)), path assert path is github.GithubObject.NotSet or isinstance(path, (str, six.text_type)), path
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
assert until is github.GithubObject.NotSet or isinstance(until, datetime.datetime), until assert until is github.GithubObject.NotSet or isinstance(until, datetime.datetime), until
assert author is github.GithubObject.NotSet or isinstance(author, (str, unicode, github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser)), author assert author is github.GithubObject.NotSet or isinstance(author, (str, six.text_type, github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser)), author
url_parameters = dict() url_parameters = dict()
if sha is not github.GithubObject.NotSet: if sha is not github.GithubObject.NotSet:
url_parameters["sha"] = sha url_parameters["sha"] = sha
@@ -1500,8 +1502,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param ref: string :param ref: string
:rtype: :class:`github.ContentFile.ContentFile` :rtype: :class:`github.ContentFile.ContentFile`
""" """
assert isinstance(path, (str, unicode)), path assert isinstance(path, (str, six.text_type)), path
assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref
# Path of '/' should be the empty string. # Path of '/' should be the empty string.
if path == '/': if path == '/':
path = '' path = ''
@@ -1510,7 +1512,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
url_parameters["ref"] = ref url_parameters["ref"] = ref
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/contents/" + urllib.quote(path), self.url + "/contents/" + six.moves.urllib.parse.quote(path),
parameters=url_parameters parameters=url_parameters
) )
if isinstance(data, list): if isinstance(data, list):
@@ -1556,7 +1558,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param per: string, must be one of day or week, day by default :param per: string, must be one of day or week, day by default
:rtype: None or list of :class:`github.View.View` :rtype: None or list of :class:`github.View.View`
""" """
assert per is github.GithubObject.NotSet or (isinstance(per, (str, unicode)) and (per == "day" or per == "week")), "per must be day or week, day by default" assert per is github.GithubObject.NotSet or (isinstance(per, (str, six.text_type)) and (per == "day" or per == "week")), "per must be day or week, day by default"
url_parameters = dict() url_parameters = dict()
if per is not github.GithubObject.NotSet: if per is not github.GithubObject.NotSet:
url_parameters["per"] = per url_parameters["per"] = per
@@ -1578,7 +1580,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param per: string, must be one of day or week, day by default :param per: string, must be one of day or week, day by default
:rtype: None or list of :class:`github.Clone.Clone` :rtype: None or list of :class:`github.Clone.Clone`
""" """
assert per is github.GithubObject.NotSet or (isinstance(per, (str, unicode)) and (per == "day" or per == "week")), "per must be day or week, day by default" assert per is github.GithubObject.NotSet or (isinstance(per, (str, six.text_type)) and (per == "day" or per == "week")), "per must be day or week, day by default"
url_parameters = dict() url_parameters = dict()
if per is not github.GithubObject.NotSet: if per is not github.GithubObject.NotSet:
url_parameters["per"] = per url_parameters["per"] = per
@@ -1630,14 +1632,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
'content': :class:`ContentFile <github.ContentFile.ContentFile>`:, 'content': :class:`ContentFile <github.ContentFile.ContentFile>`:,
'commit': :class:`Commit <github.Commit.Commit>`} 'commit': :class:`Commit <github.Commit.Commit>`}
""" """
assert isinstance(path, (str, unicode)), \ assert isinstance(path, (str, six.text_type)), \
'path must be str/unicode object' 'path must be str/unicode object'
assert isinstance(message, (str, unicode)), \ assert isinstance(message, (str, six.text_type)), \
'message must be str/unicode object' 'message must be str/unicode object'
assert isinstance(content, (str, unicode, bytes)), \ assert isinstance(content, (str, six.text_type, bytes)), \
'content must be a str/unicode object' 'content must be a str/unicode object'
assert branch is github.GithubObject.NotSet \ assert branch is github.GithubObject.NotSet \
or isinstance(branch, (str, unicode)), \ or isinstance(branch, (str, six.text_type)), \
'branch must be a str/unicode object' 'branch must be a str/unicode object'
assert author is github.GithubObject.NotSet \ assert author is github.GithubObject.NotSet \
or isinstance(author, github.InputGitAuthor), \ or isinstance(author, github.InputGitAuthor), \
@@ -1651,7 +1653,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
content = content.encode('utf-8') content = content.encode('utf-8')
content = b64encode(content).decode('utf-8') content = b64encode(content).decode('utf-8')
else: else:
if isinstance(content, unicode): if isinstance(content, six.text_type):
content = content.encode('utf-8') content = content.encode('utf-8')
content = b64encode(content) content = b64encode(content)
put_parameters = {'message': message, 'content': content} put_parameters = {'message': message, 'content': content}
@@ -1665,7 +1667,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"PUT", "PUT",
self.url + "/contents/" + urllib.quote(path), self.url + "/contents/" + six.moves.urllib.parse.quote(path),
input=put_parameters input=put_parameters
) )
@@ -1690,16 +1692,16 @@ class Repository(github.GithubObject.CompletableGithubObject):
'content': :class:`ContentFile <github.ContentFile.ContentFile>`:, 'content': :class:`ContentFile <github.ContentFile.ContentFile>`:,
'commit': :class:`Commit <github.Commit.Commit>`} 'commit': :class:`Commit <github.Commit.Commit>`}
""" """
assert isinstance(path, (str, unicode)), \ assert isinstance(path, (str, six.text_type)), \
'path must be str/unicode object' 'path must be str/unicode object'
assert isinstance(message, (str, unicode)), \ assert isinstance(message, (str, six.text_type)), \
'message must be str/unicode object' 'message must be str/unicode object'
assert isinstance(content, (str, unicode, bytes)), \ assert isinstance(content, (str, six.text_type, bytes)), \
'content must be a str/unicode object' 'content must be a str/unicode object'
assert isinstance(sha, (str, unicode)), \ assert isinstance(sha, (str, six.text_type)), \
'sha must be a str/unicode object' 'sha must be a str/unicode object'
assert branch is github.GithubObject.NotSet \ assert branch is github.GithubObject.NotSet \
or isinstance(branch, (str, unicode)), \ or isinstance(branch, (str, six.text_type)), \
'branch must be a str/unicode object' 'branch must be a str/unicode object'
assert author is github.GithubObject.NotSet \ assert author is github.GithubObject.NotSet \
or isinstance(author, github.InputGitAuthor), \ or isinstance(author, github.InputGitAuthor), \
@@ -1713,7 +1715,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
content = content.encode('utf-8') content = content.encode('utf-8')
content = b64encode(content).decode('utf-8') content = b64encode(content).decode('utf-8')
else: else:
if isinstance(content, unicode): if isinstance(content, six.text_type):
content = content.encode('utf-8') content = content.encode('utf-8')
content = b64encode(content) content = b64encode(content)
@@ -1729,7 +1731,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"PUT", "PUT",
self.url + "/contents/" + urllib.quote(path), self.url + "/contents/" + six.moves.urllib.parse.quote(path),
input=put_parameters input=put_parameters
) )
@@ -1753,14 +1755,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
'content': :class:`null <github.GithubObject.NotSet>`:, 'content': :class:`null <github.GithubObject.NotSet>`:,
'commit': :class:`Commit <github.Commit.Commit>`} 'commit': :class:`Commit <github.Commit.Commit>`}
""" """
assert isinstance(path, (str, unicode)), \ assert isinstance(path, (str, six.text_type)), \
'path must be str/unicode object' 'path must be str/unicode object'
assert isinstance(message, (str, unicode)), \ assert isinstance(message, (str, six.text_type)), \
'message must be str/unicode object' 'message must be str/unicode object'
assert isinstance(sha, (str, unicode)), \ assert isinstance(sha, (str, six.text_type)), \
'sha must be a str/unicode object' 'sha must be a str/unicode object'
assert branch is github.GithubObject.NotSet \ assert branch is github.GithubObject.NotSet \
or isinstance(branch, (str, unicode)), \ or isinstance(branch, (str, six.text_type)), \
'branch must be a str/unicode object' 'branch must be a str/unicode object'
assert author is github.GithubObject.NotSet \ assert author is github.GithubObject.NotSet \
or isinstance(author, github.InputGitAuthor), \ or isinstance(author, github.InputGitAuthor), \
@@ -1779,7 +1781,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"DELETE", "DELETE",
self.url + "/contents/" + urllib.quote(path), self.url + "/contents/" + six.moves.urllib.parse.quote(path),
input=url_parameters input=url_parameters
) )
@@ -1793,14 +1795,14 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param ref: string :param ref: string
:rtype: list of :class:`github.ContentFile.ContentFile` :rtype: list of :class:`github.ContentFile.ContentFile`
""" """
assert isinstance(path, (str, unicode)), path assert isinstance(path, (str, six.text_type)), path
assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref
url_parameters = dict() url_parameters = dict()
if ref is not github.GithubObject.NotSet: if ref is not github.GithubObject.NotSet:
url_parameters["ref"] = ref url_parameters["ref"] = ref
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/contents/" + urllib.quote(path), self.url + "/contents/" + six.moves.urllib.parse.quote(path),
parameters=url_parameters parameters=url_parameters
) )
@@ -1840,7 +1842,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.Download.Download` :rtype: :class:`github.Download.Download`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/downloads/" + str(id) self.url + "/downloads/" + str(id)
@@ -1889,7 +1891,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param sha: string :param sha: string
:rtype: :class:`github.GitBlob.GitBlob` :rtype: :class:`github.GitBlob.GitBlob`
""" """
assert isinstance(sha, (str, unicode)), sha assert isinstance(sha, (str, six.text_type)), sha
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/git/blobs/" + sha self.url + "/git/blobs/" + sha
@@ -1902,7 +1904,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param sha: string :param sha: string
:rtype: :class:`github.GitCommit.GitCommit` :rtype: :class:`github.GitCommit.GitCommit`
""" """
assert isinstance(sha, (str, unicode)), sha assert isinstance(sha, (str, six.text_type)), sha
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/git/commits/" + sha self.url + "/git/commits/" + sha
@@ -1918,7 +1920,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
prefix = "/git/refs/" prefix = "/git/refs/"
if not self._requester.FIX_REPO_GET_GIT_REF: if not self._requester.FIX_REPO_GET_GIT_REF:
prefix = "/git/" prefix = "/git/"
assert isinstance(ref, (str, unicode)), ref assert isinstance(ref, (str, six.text_type)), ref
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + prefix + ref self.url + prefix + ref
@@ -1943,7 +1945,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param sha: string :param sha: string
:rtype: :class:`github.GitTag.GitTag` :rtype: :class:`github.GitTag.GitTag`
""" """
assert isinstance(sha, (str, unicode)), sha assert isinstance(sha, (str, six.text_type)), sha
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/git/tags/" + sha self.url + "/git/tags/" + sha
@@ -1957,7 +1959,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param recursive: bool :param recursive: bool
:rtype: :class:`github.GitTree.GitTree` :rtype: :class:`github.GitTree.GitTree`
""" """
assert isinstance(sha, (str, unicode)), sha assert isinstance(sha, (str, six.text_type)), sha
assert recursive is github.GithubObject.NotSet or isinstance(recursive, bool), recursive assert recursive is github.GithubObject.NotSet or isinstance(recursive, bool), recursive
url_parameters = dict() url_parameters = dict()
if recursive is not github.GithubObject.NotSet and recursive: if recursive is not github.GithubObject.NotSet and recursive:
@@ -1976,7 +1978,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.Hook.Hook` :rtype: :class:`github.Hook.Hook`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/hooks/" + str(id) self.url + "/hooks/" + str(id)
@@ -2001,7 +2003,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param number: integer :param number: integer
:rtype: :class:`github.Issue.Issue` :rtype: :class:`github.Issue.Issue`
""" """
assert isinstance(number, (int, long)), number assert isinstance(number, six.integer_types), number
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/issues/" + str(number) self.url + "/issues/" + str(number)
@@ -2023,24 +2025,24 @@ class Repository(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue`
""" """
assert milestone is github.GithubObject.NotSet or milestone == "*" or milestone == "none" or isinstance(milestone, github.Milestone.Milestone), milestone assert milestone is github.GithubObject.NotSet or milestone == "*" or milestone == "none" or isinstance(milestone, github.Milestone.Milestone), milestone
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee assert assignee is github.GithubObject.NotSet or isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee
assert mentioned is github.GithubObject.NotSet or isinstance(mentioned, github.NamedUser.NamedUser), mentioned assert mentioned is github.GithubObject.NotSet or isinstance(mentioned, github.NamedUser.NamedUser), mentioned
assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels assert labels is github.GithubObject.NotSet or all(isinstance(element, github.Label.Label) for element in labels), labels
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
assert creator is github.GithubObject.NotSet or isinstance(creator, github.NamedUser.NamedUser) or isinstance(creator, (str, unicode)), creator assert creator is github.GithubObject.NotSet or isinstance(creator, github.NamedUser.NamedUser) or isinstance(creator, (str, six.text_type)), creator
url_parameters = dict() url_parameters = dict()
if milestone is not github.GithubObject.NotSet: if milestone is not github.GithubObject.NotSet:
if isinstance(milestone, (str, unicode)): if isinstance(milestone, (str, six.text_type)):
url_parameters["milestone"] = milestone url_parameters["milestone"] = milestone
else: else:
url_parameters["milestone"] = milestone._identity url_parameters["milestone"] = milestone._identity
if state is not github.GithubObject.NotSet: if state is not github.GithubObject.NotSet:
url_parameters["state"] = state url_parameters["state"] = state
if assignee is not github.GithubObject.NotSet: if assignee is not github.GithubObject.NotSet:
if isinstance(assignee, (str, unicode)): if isinstance(assignee, (str, six.text_type)):
url_parameters["assignee"] = assignee url_parameters["assignee"] = assignee
else: else:
url_parameters["assignee"] = assignee._identity url_parameters["assignee"] = assignee._identity
@@ -2055,7 +2057,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
if since is not github.GithubObject.NotSet: if since is not github.GithubObject.NotSet:
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
if creator is not github.GithubObject.NotSet: if creator is not github.GithubObject.NotSet:
if isinstance(creator, (str, unicode)): if isinstance(creator, (str, six.text_type)):
url_parameters["creator"] = creator url_parameters["creator"] = creator
else: else:
url_parameters["creator"] = creator._identity url_parameters["creator"] = creator._identity
@@ -2074,8 +2076,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param since: datetime.datetime :param since: datetime.datetime
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment`
""" """
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
url_parameters = dict() url_parameters = dict()
if sort is not github.GithubObject.NotSet: if sort is not github.GithubObject.NotSet:
@@ -2097,7 +2099,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.IssueEvent.IssueEvent` :rtype: :class:`github.IssueEvent.IssueEvent`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/issues/events/" + str(id), self.url + "/issues/events/" + str(id),
@@ -2124,7 +2126,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param id: integer :param id: integer
:rtype: :class:`github.RepositoryKey.RepositoryKey` :rtype: :class:`github.RepositoryKey.RepositoryKey`
""" """
assert isinstance(id, (int, long)), id assert isinstance(id, six.integer_types), id
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/keys/" + str(id) self.url + "/keys/" + str(id)
@@ -2149,10 +2151,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param name: string :param name: string
:rtype: :class:`github.Label.Label` :rtype: :class:`github.Label.Label`
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/labels/" + urllib.quote(name) self.url + "/labels/" + six.moves.urllib.parse.quote(name)
) )
return github.Label.Label(self._requester, headers, data, completed=True) return github.Label.Label(self._requester, headers, data, completed=True)
@@ -2197,7 +2199,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param number: integer :param number: integer
:rtype: :class:`github.Milestone.Milestone` :rtype: :class:`github.Milestone.Milestone`
""" """
assert isinstance(number, (int, long)), number assert isinstance(number, six.integer_types), number
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/milestones/" + str(number) self.url + "/milestones/" + str(number)
@@ -2212,9 +2214,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param direction: string :param direction: string
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Milestone.Milestone` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Milestone.Milestone`
""" """
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
url_parameters = dict() url_parameters = dict()
if state is not github.GithubObject.NotSet: if state is not github.GithubObject.NotSet:
url_parameters["state"] = state url_parameters["state"] = state
@@ -2247,7 +2249,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param number: integer :param number: integer
:rtype: :class:`github.PullRequest.PullRequest` :rtype: :class:`github.PullRequest.PullRequest`
""" """
assert isinstance(number, (int, long)), number assert isinstance(number, six.integer_types), number
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/pulls/" + str(number) self.url + "/pulls/" + str(number)
@@ -2264,11 +2266,11 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param head: string :param head: string
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequest.PullRequest` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequest.PullRequest`
""" """
assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state assert state is github.GithubObject.NotSet or isinstance(state, (str, six.text_type)), state
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
assert base is github.GithubObject.NotSet or isinstance(base, (str, unicode)), base assert base is github.GithubObject.NotSet or isinstance(base, (str, six.text_type)), base
assert head is github.GithubObject.NotSet or isinstance(head, (str, unicode)), head assert head is github.GithubObject.NotSet or isinstance(head, (str, six.text_type)), head
url_parameters = dict() url_parameters = dict()
if state is not github.GithubObject.NotSet: if state is not github.GithubObject.NotSet:
url_parameters["state"] = state url_parameters["state"] = state
@@ -2305,8 +2307,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param since: datetime.datetime :param since: datetime.datetime
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment`
""" """
assert sort is github.GithubObject.NotSet or isinstance(sort, (str, unicode)), sort assert sort is github.GithubObject.NotSet or isinstance(sort, (str, six.text_type)), sort
assert direction is github.GithubObject.NotSet or isinstance(direction, (str, unicode)), direction assert direction is github.GithubObject.NotSet or isinstance(direction, (str, six.text_type)), direction
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
url_parameters = dict() url_parameters = dict()
if sort is not github.GithubObject.NotSet: if sort is not github.GithubObject.NotSet:
@@ -2328,7 +2330,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param ref: string :param ref: string
:rtype: :class:`github.ContentFile.ContentFile` :rtype: :class:`github.ContentFile.ContentFile`
""" """
assert ref is github.GithubObject.NotSet or isinstance(ref, (str, unicode)), ref assert ref is github.GithubObject.NotSet or isinstance(ref, (str, six.text_type)), ref
url_parameters = dict() url_parameters = dict()
if ref is not github.GithubObject.NotSet: if ref is not github.GithubObject.NotSet:
url_parameters["ref"] = ref url_parameters["ref"] = ref
@@ -2507,7 +2509,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
self.url + "/releases/" + str(id) self.url + "/releases/" + str(id)
) )
return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) return github.GitRelease.GitRelease(self._requester, headers, data, completed=True)
elif isinstance(id, (str, unicode)): elif isinstance(id, (str, six.text_type)):
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
self.url + "/releases/tags/" + id self.url + "/releases/tags/" + id
@@ -2567,7 +2569,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param assignee: string or :class:`github.NamedUser.NamedUser` :param assignee: string or :class:`github.NamedUser.NamedUser`
:rtype: bool :rtype: bool
""" """
assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, unicode)), assignee assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, (str, six.text_type)), assignee
if isinstance(assignee, github.NamedUser.NamedUser): if isinstance(assignee, github.NamedUser.NamedUser):
assignee = assignee._identity assignee = assignee._identity
@@ -2584,7 +2586,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param collaborator: string or :class:`github.NamedUser.NamedUser` :param collaborator: string or :class:`github.NamedUser.NamedUser`
:rtype: bool :rtype: bool
""" """
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator
if isinstance(collaborator, github.NamedUser.NamedUser): if isinstance(collaborator, github.NamedUser.NamedUser):
collaborator = collaborator._identity collaborator = collaborator._identity
@@ -2603,10 +2605,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue`
""" """
assert state in ["open", "closed"], state assert state in ["open", "closed"], state
assert isinstance(keyword, (str, unicode)), keyword assert isinstance(keyword, (str, six.text_type)), keyword
headers, data = self._requester.requestJsonAndCheck( headers, data = self._requester.requestJsonAndCheck(
"GET", "GET",
"/legacy/issues/search/" + self.owner.login + "/" + self.name + "/" + state + "/" + urllib.quote(keyword) "/legacy/issues/search/" + self.owner.login + "/" + self.name + "/" + state + "/" + six.moves.urllib.parse.quote(keyword)
) )
return [ return [
github.Issue.Issue(self._requester, headers, github.Legacy.convertIssue(element), completed=False) github.Issue.Issue(self._requester, headers, github.Legacy.convertIssue(element), completed=False)
@@ -2637,9 +2639,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param commit_message: string :param commit_message: string
:rtype: :class:`github.Commit.Commit` :rtype: :class:`github.Commit.Commit`
""" """
assert isinstance(base, (str, unicode)), base assert isinstance(base, (str, six.text_type)), base
assert isinstance(head, (str, unicode)), head assert isinstance(head, (str, six.text_type)), head
assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, unicode)), commit_message assert commit_message is github.GithubObject.NotSet or isinstance(commit_message, (str, six.text_type)), commit_message
post_parameters = { post_parameters = {
"base": base, "base": base,
"head": head, "head": head,
@@ -2678,7 +2680,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
:param collaborator: string or :class:`github.NamedUser.NamedUser` :param collaborator: string or :class:`github.NamedUser.NamedUser`
:rtype: None :rtype: None
""" """
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, unicode)), collaborator assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, (str, six.text_type)), collaborator
if isinstance(collaborator, github.NamedUser.NamedUser): if isinstance(collaborator, github.NamedUser.NamedUser):
collaborator = collaborator._identity collaborator = collaborator._identity
@@ -2709,10 +2711,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
return self._hub("unsubscribe", event, callback, github.GithubObject.NotSet) return self._hub("unsubscribe", event, callback, github.GithubObject.NotSet)
def _hub(self, mode, event, callback, secret): def _hub(self, mode, event, callback, secret):
assert isinstance(mode, (str, unicode)), mode assert isinstance(mode, (str, six.text_type)), mode
assert isinstance(event, (str, unicode)), event assert isinstance(event, (str, six.text_type)), event
assert isinstance(callback, (str, unicode)), callback assert isinstance(callback, (str, six.text_type)), callback
assert secret is github.GithubObject.NotSet or isinstance(secret, (str, unicode)), secret assert secret is github.GithubObject.NotSet or isinstance(secret, (str, six.text_type)), secret
post_parameters = { post_parameters = {
"hub.mode": mode, "hub.mode": mode,
+1
View File
@@ -35,6 +35,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+14 -12
View File
@@ -52,6 +52,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import base64 import base64
import json import json
import logging import logging
@@ -61,12 +62,13 @@ import re
import requests import requests
import sys import sys
import time import time
import urllib import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import urlparse import six.moves.urllib.parse
from io import IOBase from io import IOBase
import Consts from . import Consts
import GithubException from . import GithubException
import six
atLeastPython3 = sys.hexversion >= 0x03000000 atLeastPython3 = sys.hexversion >= 0x03000000
@@ -80,9 +82,9 @@ class RequestsResponse:
def getheaders(self): def getheaders(self):
if atLeastPython3: if atLeastPython3:
return self.headers.items() return list(self.headers.items())
else: else:
return self.headers.iteritems() return six.iteritems(self.headers)
def read(self): def read(self):
return self.text return self.text
@@ -243,7 +245,7 @@ class Requester:
self.__authorizationHeader = None self.__authorizationHeader = None
self.__base_url = base_url self.__base_url = base_url
o = urlparse.urlparse(base_url) o = six.moves.urllib.parse.urlparse(base_url)
self.__hostname = o.hostname self.__hostname = o.hostname
self.__port = o.port self.__port = o.port
self.__prefix = o.path self.__prefix = o.path
@@ -290,7 +292,7 @@ class Requester:
def __customConnection(self, url): def __customConnection(self, url):
cnx = None cnx = None
if not url.startswith("/"): if not url.startswith("/"):
o = urlparse.urlparse(url) o = six.moves.urllib.parse.urlparse(url)
if o.hostname != self.__hostname or \ if o.hostname != self.__hostname or \
(o.port and o.port != self.__port) or \ (o.port and o.port != self.__port) or \
(o.scheme != self.__scheme and not (o.scheme == "https" and self.__scheme == "http")): # issue80 (o.scheme != self.__scheme and not (o.scheme == "https" and self.__scheme == "http")): # issue80
@@ -341,7 +343,7 @@ class Requester:
eol = "\r\n" eol = "\r\n"
encoded_input = "" encoded_input = ""
for name, value in input.iteritems(): for name, value in six.iteritems(input):
encoded_input += "--" + boundary + eol encoded_input += "--" + boundary + eol
encoded_input += "Content-Disposition: form-data; name=\"" + name + "\"" + eol encoded_input += "Content-Disposition: form-data; name=\"" + name + "\"" + eol
encoded_input += eol encoded_input += eol
@@ -428,7 +430,7 @@ class Requester:
return self.__requestRaw(original_cnx, verb, url, requestHeaders, input) return self.__requestRaw(original_cnx, verb, url, requestHeaders, input)
if status == 301 and 'location' in responseHeaders: if status == 301 and 'location' in responseHeaders:
o = urlparse.urlparse(responseHeaders['location']) o = six.moves.urllib.parse.urlparse(responseHeaders['location'])
return self.__requestRaw(original_cnx, verb, o.path, requestHeaders, input) return self.__requestRaw(original_cnx, verb, o.path, requestHeaders, input)
return status, responseHeaders, output return status, responseHeaders, output
@@ -446,7 +448,7 @@ class Requester:
if url.startswith("/"): if url.startswith("/"):
url = self.__prefix + url url = self.__prefix + url
else: else:
o = urlparse.urlparse(url) o = six.moves.urllib.parse.urlparse(url)
assert o.hostname in [self.__hostname, "uploads.github.com", "status.github.com"], o.hostname assert o.hostname in [self.__hostname, "uploads.github.com", "status.github.com"], o.hostname
assert o.path.startswith((self.__prefix, "/api/")) assert o.path.startswith((self.__prefix, "/api/"))
assert o.port == self.__port assert o.port == self.__port
@@ -459,7 +461,7 @@ class Requester:
if len(parameters) == 0: if len(parameters) == 0:
return url return url
else: else:
return url + "?" + urllib.urlencode(parameters) return url + "?" + six.moves.urllib.parse.urlencode(parameters)
def __createConnection(self): def __createConnection(self):
kwds = {} kwds = {}
+1
View File
@@ -22,6 +22,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
+1
View File
@@ -22,6 +22,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -22,6 +22,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github import github
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.NamedUser import github.NamedUser
+1
View File
@@ -31,6 +31,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.Commit import github.Commit
+9 -7
View File
@@ -41,6 +41,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
import github.PaginatedList import github.PaginatedList
@@ -48,7 +49,8 @@ import github.Repository
import github.NamedUser import github.NamedUser
import github.Organization import github.Organization
import Consts from . import Consts
import six
class Team(github.GithubObject.CompletableGithubObject): class Team(github.GithubObject.CompletableGithubObject):
@@ -179,7 +181,7 @@ class Team(github.GithubObject.CompletableGithubObject):
""" """
assert isinstance(member, github.NamedUser.NamedUser), member assert isinstance(member, github.NamedUser.NamedUser), member
assert role is github.GithubObject.NotSet or isinstance( assert role is github.GithubObject.NotSet or isinstance(
role, (str, unicode)), role role, (str, six.text_type)), role
if role is not github.GithubObject.NotSet: if role is not github.GithubObject.NotSet:
assert role in ['member', 'maintainer'] assert role in ['member', 'maintainer']
put_parameters = { put_parameters = {
@@ -243,10 +245,10 @@ class Team(github.GithubObject.CompletableGithubObject):
:param privacy: string :param privacy: string
:rtype: None :rtype: None
""" """
assert isinstance(name, (str, unicode)), name assert isinstance(name, (str, six.text_type)), name
assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description assert description is github.GithubObject.NotSet or isinstance(description, (str, six.text_type)), description
assert permission is github.GithubObject.NotSet or isinstance(permission, (str, unicode)), permission assert permission is github.GithubObject.NotSet or isinstance(permission, (str, six.text_type)), permission
assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, unicode)), privacy assert privacy is github.GithubObject.NotSet or isinstance(privacy, (str, six.text_type)), privacy
post_parameters = { post_parameters = {
"name": name, "name": name,
} }
@@ -269,7 +271,7 @@ class Team(github.GithubObject.CompletableGithubObject):
:param role: string :param role: string
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
""" """
assert role is github.GithubObject.NotSet or isinstance(role, (str, unicode)), role assert role is github.GithubObject.NotSet or isinstance(role, (str, six.text_type)), role
url_parameters = dict() url_parameters = dict()
if role is not github.GithubObject.NotSet: if role is not github.GithubObject.NotSet:
assert role in ['member', 'maintainer', 'all'] assert role in ['member', 'maintainer', 'all']
+1
View File
@@ -22,6 +22,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -31,6 +31,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+1
View File
@@ -26,6 +26,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import github.GithubObject import github.GithubObject
+5 -4
View File
@@ -37,13 +37,14 @@ like :class:`github.NamedUser.NamedUser` or :class:`github.Repository.Repository
All classes inherit from :class:`github.GithubObject.GithubObject`. All classes inherit from :class:`github.GithubObject.GithubObject`.
""" """
from __future__ import absolute_import
import logging import logging
from github.MainClass import Github, GithubIntegration from github.MainClass import Github, GithubIntegration
from GithubException import GithubException, BadCredentialsException, UnknownObjectException, BadUserAgentException, RateLimitExceededException, BadAttributeException, TwoFactorException from .GithubException import GithubException, BadCredentialsException, UnknownObjectException, BadUserAgentException, RateLimitExceededException, BadAttributeException, TwoFactorException
from InputFileContent import InputFileContent from .InputFileContent import InputFileContent
from InputGitAuthor import InputGitAuthor from .InputGitAuthor import InputGitAuthor
from InputGitTreeElement import InputGitTreeElement from .InputGitTreeElement import InputGitTreeElement
def enable_console_debug_logging(): # pragma no cover (Function useful only outside test environment) def enable_console_debug_logging(): # pragma no cover (Function useful only outside test environment)
+1
View File
@@ -1,5 +1,6 @@
requests>=2.14.0 requests>=2.14.0
pyjwt pyjwt
six
sphinx<1.8 sphinx<1.8
sphinx-rtd-theme<0.5 sphinx-rtd-theme<0.5
Deprecated Deprecated
+1
View File
@@ -28,6 +28,7 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import sys import sys
import os.path import os.path
+5 -3
View File
@@ -26,6 +26,8 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
from __future__ import print_function
import os import os
import subprocess import subprocess
@@ -153,17 +155,17 @@ def findHeadersAndFiles():
elif fullname.endswith(".pyc"): elif fullname.endswith(".pyc"):
pass pass
else: else:
print "Don't know what to do with", filename print("Don't know what to do with", filename)
def main(): def main():
for header, filename in findHeadersAndFiles(): for header, filename in findHeadersAndFiles():
print "Analyzing", filename print("Analyzing", filename)
with open(filename) as f: with open(filename) as f:
lines = list(line.rstrip() for line in f) lines = list(line.rstrip() for line in f)
newLines = header.fix(filename, lines) newLines = header.fix(filename, lines)
if newLines != lines: if newLines != lines:
print " => actually modifying", filename print(" => actually modifying", filename)
with open(filename, "w") as f: with open(filename, "w") as f:
for line in newLines: for line in newLines:
f.write(line + "\n") f.write(line + "\n")
+86 -85
View File
@@ -40,90 +40,91 @@
# # # #
################################################################################ ################################################################################
from AuthenticatedUser import * from __future__ import absolute_import
from Authentication import * from .AuthenticatedUser import *
from Authorization import * from .Authentication import *
from Branch import * from .Authorization import *
from BranchProtection import * from .Branch import *
from Commit import * from .BranchProtection import *
from CommitCombinedStatus import * from .Commit import *
from CommitComment import * from .CommitCombinedStatus import *
from CommitStatus import * from .CommitComment import *
from ContentFile import * from .CommitStatus import *
from Download import * from .ContentFile import *
from Event import * from .Download import *
from Gist import * from .Event import *
from GistComment import * from .Gist import *
from GitBlob import * from .GistComment import *
from GitCommit import * from .GitBlob import *
from Github_ import * from .GitCommit import *
from GitRef import * from .Github_ import *
from GitRelease import * from .GitRef import *
from GitReleaseAsset import * from .GitRelease import *
from GitTag import * from .GitReleaseAsset import *
from GitTree import * from .GitTag import *
from Hook import * from .GitTree import *
from Issue import * from .Hook import *
from IssueComment import * from .Issue import *
from Reaction import * from .IssueComment import *
from IssueEvent import * from .Reaction import *
from License import * from .IssueEvent import *
from Label import * from .License import *
from Milestone import * from .Label import *
from NamedUser import * from .Milestone import *
from Markdown import * from .NamedUser import *
from Notification import * from .Markdown import *
from OrganizationHasInMembers import * from .Notification import *
from Organization import * from .OrganizationHasInMembers import *
from Project import * from .Organization import *
from PullRequest import * from .Project import *
from PullRequestComment import * from .PullRequest import *
from PullRequestReview import * from .PullRequestComment import *
from PullRequestFile import * from .PullRequestReview import *
from RateLimiting import * from .PullRequestFile import *
from Repository import * from .RateLimiting import *
from RepositoryKey import * from .Repository import *
from RequiredPullRequestReviews import * from .RepositoryKey import *
from RequiredStatusChecks import * from .RequiredPullRequestReviews import *
from SourceImport import * from .RequiredStatusChecks import *
from Tag import * from .SourceImport import *
from Team import * from .Tag import *
from Traffic import * from .Team import *
from UserKey import * from .Traffic import *
from Migration import * from .UserKey import *
from GithubIntegration import * from .Migration import *
from .GithubIntegration import *
from PaginatedList import * from .PaginatedList import *
from Exceptions import * from .Exceptions import *
from Enterprise import * from .Enterprise import *
from Logging_ import * from .Logging_ import *
from RawData import * from .RawData import *
from ConditionalRequestUpdate import * from .ConditionalRequestUpdate import *
from Persistence import * from .Persistence import *
from ExposeAllAttributes import * from .ExposeAllAttributes import *
from BadAttributes import * from .BadAttributes import *
from Equality import * from .Equality import *
from Search import * from .Search import *
from Retry import * from .Retry import *
from Issue33 import * from .Issue33 import *
from Issue50 import * from .Issue50 import *
from Issue54 import * from .Issue54 import *
from Issue80 import * from .Issue80 import *
from Issue87 import * from .Issue87 import *
from Issue131 import * from .Issue131 import *
from Issue133 import * from .Issue133 import *
from Issue134 import * from .Issue134 import *
from Issue139 import * from .Issue139 import *
from Issue140 import * from .Issue140 import *
from Issue142 import * from .Issue142 import *
from Issue158 import * from .Issue158 import *
from Issue174 import * from .Issue174 import *
from Issue214 import * from .Issue214 import *
from Issue216 import * from .Issue216 import *
from Issue278 import * from .Issue278 import *
from Issue494 import * from .Issue494 import *
from Issue572 import * from .Issue572 import *
from Issue937 import * from .Issue937 import *
from Issue945 import * from .Issue945 import *
from Issue823 import * from .Issue823 import *
+5 -4
View File
@@ -32,7 +32,8 @@
# # # #
################################################################################ ################################################################################
import Framework from __future__ import absolute_import
from . import Framework
import github import github
import datetime import datetime
@@ -167,13 +168,13 @@ class AuthenticatedUser(Framework.TestCase):
def testCreateGist(self): def testCreateGist(self):
gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub") gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}, "Gist created by PyGithub")
self.assertEqual(gist.description, "Gist created by PyGithub") self.assertEqual(gist.description, "Gist created by PyGithub")
self.assertEqual(gist.files.keys(), ["foobar.txt"]) self.assertEqual(list(gist.files.keys()), ["foobar.txt"])
self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub") self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
def testCreateGistWithoutDescription(self): def testCreateGistWithoutDescription(self):
gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")}) gist = self.user.create_gist(True, {"foobar.txt": github.InputFileContent("File created by PyGithub")})
self.assertEqual(gist.description, None) self.assertEqual(gist.description, None)
self.assertEqual(gist.files.keys(), ["foobar.txt"]) self.assertEqual(list(gist.files.keys()), ["foobar.txt"])
self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub") self.assertEqual(gist.files["foobar.txt"].content, "File created by PyGithub")
def testCreateKey(self): def testCreateKey(self):
@@ -245,7 +246,7 @@ class AuthenticatedUser(Framework.TestCase):
self.assertListKeyEqual(self.user.get_notifications(all=True), lambda n: n.id, []) self.assertListKeyEqual(self.user.get_notifications(all=True), lambda n: n.id, [])
def testMarkNotificationsAsRead(self): def testMarkNotificationsAsRead(self):
self.user.mark_notifications_as_read(datetime.datetime(2018, 10, 18, 18, 20, 01, 0)) self.user.mark_notifications_as_read(datetime.datetime(2018, 10, 18, 18, 20, 0o1, 0))
def testGetTeams(self): def testGetTeams(self):
self.assertListKeyEqual(self.user.get_teams(), lambda t: t.name, ["Owners", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries"]) self.assertListKeyEqual(self.user.get_teams(), lambda t: t.name, ["Owners", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries", "Honoraries"])
+2 -1
View File
@@ -28,7 +28,8 @@
# # # #
################################################################################ ################################################################################
import Framework from __future__ import absolute_import
from . import Framework
import github import github
+2 -1
View File
@@ -27,7 +27,8 @@
# # # #
################################################################################ ################################################################################
import Framework from __future__ import absolute_import
from . import Framework
import datetime import datetime
+9 -7
View File
@@ -26,10 +26,12 @@
# # # #
################################################################################ ################################################################################
from __future__ import absolute_import
import datetime import datetime
import Framework from . import Framework
import github import github
import six
# Replay data is forged to simulate bad things returned by Github # Replay data is forged to simulate bad things returned by Github
@@ -41,7 +43,7 @@ class BadAttributes(Framework.TestCase):
with self.assertRaises(github.BadAttributeException) as raisedexp: with self.assertRaises(github.BadAttributeException) as raisedexp:
user.name user.name
self.assertEqual(raisedexp.exception.actual_value, 42) self.assertEqual(raisedexp.exception.actual_value, 42)
self.assertEqual(raisedexp.exception.expected_type, (str, unicode)) self.assertEqual(raisedexp.exception.expected_type, (str, six.text_type))
self.assertEqual(raisedexp.exception.transformation_exception, None) self.assertEqual(raisedexp.exception.transformation_exception, None)
def testBadAttributeTransformation(self): def testBadAttributeTransformation(self):
@@ -51,7 +53,7 @@ class BadAttributes(Framework.TestCase):
with self.assertRaises(github.BadAttributeException) as raisedexp: with self.assertRaises(github.BadAttributeException) as raisedexp:
user.created_at user.created_at
self.assertEqual(raisedexp.exception.actual_value, "foobar") self.assertEqual(raisedexp.exception.actual_value, "foobar")
self.assertEqual(raisedexp.exception.expected_type, (str, unicode)) self.assertEqual(raisedexp.exception.expected_type, (str, six.text_type))
self.assertEqual(raisedexp.exception.transformation_exception.__class__, ValueError) self.assertEqual(raisedexp.exception.transformation_exception.__class__, ValueError)
self.assertEqual(raisedexp.exception.transformation_exception.args, ("time data 'foobar' does not match format '%Y-%m-%dT%H:%M:%SZ'",)) self.assertEqual(raisedexp.exception.transformation_exception.args, ("time data 'foobar' does not match format '%Y-%m-%dT%H:%M:%SZ'",))
@@ -62,7 +64,7 @@ class BadAttributes(Framework.TestCase):
with self.assertRaises(github.BadAttributeException) as raisedexp: with self.assertRaises(github.BadAttributeException) as raisedexp:
user.updated_at user.updated_at
self.assertEqual(raisedexp.exception.actual_value, 42) self.assertEqual(raisedexp.exception.actual_value, 42)
self.assertEqual(raisedexp.exception.expected_type, (str, unicode)) self.assertEqual(raisedexp.exception.expected_type, (str, six.text_type))
self.assertEqual(raisedexp.exception.transformation_exception, None) self.assertEqual(raisedexp.exception.transformation_exception, None)
def testBadSimpleAttributeInList(self): def testBadSimpleAttributeInList(self):
@@ -72,7 +74,7 @@ class BadAttributes(Framework.TestCase):
with self.assertRaises(github.BadAttributeException) as raisedexp: with self.assertRaises(github.BadAttributeException) as raisedexp:
hook.events hook.events
self.assertEqual(raisedexp.exception.actual_value, ["push", 42]) self.assertEqual(raisedexp.exception.actual_value, ["push", 42])
self.assertEqual(raisedexp.exception.expected_type, [(str, unicode)]) self.assertEqual(raisedexp.exception.expected_type, [(str, six.text_type)])
self.assertEqual(raisedexp.exception.transformation_exception, None) self.assertEqual(raisedexp.exception.transformation_exception, None)
def testBadAttributeInClassAttribute(self): def testBadAttributeInClassAttribute(self):
@@ -99,7 +101,7 @@ class BadAttributes(Framework.TestCase):
with self.assertRaises(github.BadAttributeException) as raisedexp: with self.assertRaises(github.BadAttributeException) as raisedexp:
gist.files gist.files
self.assertEqual(raisedexp.exception.actual_value, {"test.py": 42}) self.assertEqual(raisedexp.exception.actual_value, {"test.py": 42})
self.assertEqual(raisedexp.exception.expected_type, {(str, unicode): dict}) self.assertEqual(raisedexp.exception.expected_type, {(str, six.text_type): dict})
self.assertEqual(raisedexp.exception.transformation_exception, None) self.assertEqual(raisedexp.exception.transformation_exception, None)
def testIssue195(self): def testIssue195(self):
@@ -115,5 +117,5 @@ class BadAttributes(Framework.TestCase):
with self.assertRaises(github.BadAttributeException) as raisedexp: with self.assertRaises(github.BadAttributeException) as raisedexp:
hook.events hook.events
self.assertEqual(raisedexp.exception.actual_value, [["commit_comment", "create", "delete", "download", "follow", "fork", "fork_apply", "gist", "gollum", "issue_comment", "issues", "member", "public", "pull_request", "pull_request_review_comment", "push", "status", "team_add", "watch"]]) self.assertEqual(raisedexp.exception.actual_value, [["commit_comment", "create", "delete", "download", "follow", "fork", "fork_apply", "gist", "gollum", "issue_comment", "issues", "member", "public", "pull_request", "pull_request_review_comment", "push", "status", "team_add", "watch"]])
self.assertEqual(raisedexp.exception.expected_type, [(str, unicode)]) self.assertEqual(raisedexp.exception.expected_type, [(str, six.text_type)])
self.assertEqual(raisedexp.exception.transformation_exception, None) self.assertEqual(raisedexp.exception.transformation_exception, None)
+2 -1
View File
@@ -30,7 +30,8 @@
# # # #
################################################################################ ################################################################################
import Framework from __future__ import absolute_import
from . import Framework
import github import github
+2 -1
View File
@@ -22,7 +22,8 @@
# # # #
################################################################################ ################################################################################
import Framework from __future__ import absolute_import
from . import Framework
class BranchProtection(Framework.TestCase): class BranchProtection(Framework.TestCase):

Some files were not shown because too many files have changed in this diff Show More