mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Drop Python 2 support (#1329)
With the Python 2 deadline gone, it's time to move with the times and switch to Python 3 only.
This commit is contained in:
+133
-193
@@ -85,14 +85,11 @@
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import urllib.parse
|
||||
from base64 import b64encode
|
||||
|
||||
import six
|
||||
import six.moves.urllib.parse
|
||||
from deprecated import deprecated
|
||||
|
||||
import github.Branch
|
||||
@@ -783,10 +780,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: None
|
||||
"""
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(
|
||||
collaborator, (str, six.text_type)
|
||||
collaborator, str
|
||||
), collaborator
|
||||
assert permission is github.GithubObject.NotSet or isinstance(
|
||||
permission, (str, six.text_type)
|
||||
permission, str
|
||||
), permission
|
||||
|
||||
if isinstance(collaborator, github.NamedUser.NamedUser):
|
||||
@@ -815,7 +812,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: string
|
||||
"""
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(
|
||||
collaborator, (str, six.text_type)
|
||||
collaborator, str
|
||||
), collaborator
|
||||
if isinstance(collaborator, github.NamedUser.NamedUser):
|
||||
collaborator = collaborator._identity
|
||||
@@ -854,8 +851,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param head: string
|
||||
:rtype: :class:`github.Comparison.Comparison`
|
||||
"""
|
||||
assert isinstance(base, (str, six.text_type)), base
|
||||
assert isinstance(head, (str, six.text_type)), head
|
||||
assert isinstance(base, str), base
|
||||
assert isinstance(head, str), head
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/compare/" + base + "..." + head
|
||||
)
|
||||
@@ -870,8 +867,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param encoding: string
|
||||
:rtype: :class:`github.GitBlob.GitBlob`
|
||||
"""
|
||||
assert isinstance(content, (str, six.text_type)), content
|
||||
assert isinstance(encoding, (str, six.text_type)), encoding
|
||||
assert isinstance(content, str), content
|
||||
assert isinstance(encoding, str), encoding
|
||||
post_parameters = {
|
||||
"content": content,
|
||||
"encoding": encoding,
|
||||
@@ -898,7 +895,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param committer: :class:`github.InputGitAuthor.InputGitAuthor`
|
||||
:rtype: :class:`github.GitCommit.GitCommit`
|
||||
"""
|
||||
assert isinstance(message, (str, six.text_type)), message
|
||||
assert isinstance(message, str), message
|
||||
assert isinstance(tree, github.GitTree.GitTree), tree
|
||||
assert all(
|
||||
isinstance(element, github.GitCommit.GitCommit) for element in parents
|
||||
@@ -932,8 +929,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param sha: string
|
||||
:rtype: :class:`github.GitRef.GitRef`
|
||||
"""
|
||||
assert isinstance(ref, (str, six.text_type)), ref
|
||||
assert isinstance(sha, (str, six.text_type)), sha
|
||||
assert isinstance(ref, str), ref
|
||||
assert isinstance(sha, str), sha
|
||||
post_parameters = {
|
||||
"ref": ref,
|
||||
"sha": sha,
|
||||
@@ -979,16 +976,15 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param target_commitish: string or :class:`github.Branch.Branch` or :class:`github.Commit.Commit` or :class:`github.GitCommit.GitCommit`
|
||||
:rtype: :class:`github.GitRelease.GitRelease`
|
||||
"""
|
||||
assert isinstance(tag, (str, six.text_type)), tag
|
||||
assert isinstance(name, (str, six.text_type)), name
|
||||
assert isinstance(message, (str, six.text_type)), message
|
||||
assert isinstance(tag, str), tag
|
||||
assert isinstance(name, str), name
|
||||
assert isinstance(message, str), message
|
||||
assert isinstance(draft, bool), draft
|
||||
assert isinstance(prerelease, bool), prerelease
|
||||
assert target_commitish is github.GithubObject.NotSet or isinstance(
|
||||
target_commitish,
|
||||
(
|
||||
str,
|
||||
six.text_type,
|
||||
github.Branch.Branch,
|
||||
github.Commit.Commit,
|
||||
github.GitCommit.GitCommit,
|
||||
@@ -1001,7 +997,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
"draft": draft,
|
||||
"prerelease": prerelease,
|
||||
}
|
||||
if isinstance(target_commitish, (str, six.text_type)):
|
||||
if isinstance(target_commitish, str):
|
||||
post_parameters["target_commitish"] = target_commitish
|
||||
elif isinstance(target_commitish, github.Branch.Branch):
|
||||
post_parameters["target_commitish"] = target_commitish.name
|
||||
@@ -1028,10 +1024,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param tagger: :class:`github.InputGitAuthor.InputGitAuthor`
|
||||
:rtype: :class:`github.GitTag.GitTag`
|
||||
"""
|
||||
assert isinstance(tag, (str, six.text_type)), tag
|
||||
assert isinstance(message, (str, six.text_type)), message
|
||||
assert isinstance(object, (str, six.text_type)), object
|
||||
assert isinstance(type, (str, six.text_type)), type
|
||||
assert isinstance(tag, str), tag
|
||||
assert isinstance(message, str), message
|
||||
assert isinstance(object, str), object
|
||||
assert isinstance(type, str), type
|
||||
assert tagger is github.GithubObject.NotSet or isinstance(
|
||||
tagger, github.InputGitAuthor
|
||||
), tagger
|
||||
@@ -1086,10 +1082,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param active: bool
|
||||
:rtype: :class:`github.Hook.Hook`
|
||||
"""
|
||||
assert isinstance(name, (str, six.text_type)), name
|
||||
assert isinstance(name, str), name
|
||||
assert isinstance(config, dict), config
|
||||
assert events is github.GithubObject.NotSet or all(
|
||||
isinstance(element, (str, six.text_type)) for element in events
|
||||
isinstance(element, str) for element in events
|
||||
), events
|
||||
assert active is github.GithubObject.NotSet or isinstance(active, bool), active
|
||||
post_parameters = {
|
||||
@@ -1124,26 +1120,22 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param labels: list of :class:`github.Label.Label`
|
||||
:rtype: :class:`github.Issue.Issue`
|
||||
"""
|
||||
assert isinstance(title, (str, six.text_type)), title
|
||||
assert body is github.GithubObject.NotSet or isinstance(
|
||||
body, (str, six.text_type)
|
||||
), body
|
||||
assert isinstance(title, str), title
|
||||
assert body is github.GithubObject.NotSet or isinstance(body, str), body
|
||||
assert (
|
||||
assignee is github.GithubObject.NotSet
|
||||
or isinstance(assignee, github.NamedUser.NamedUser)
|
||||
or isinstance(assignee, (str, six.text_type))
|
||||
or isinstance(assignee, str)
|
||||
), assignee
|
||||
assert assignees is github.GithubObject.NotSet or all(
|
||||
isinstance(element, github.NamedUser.NamedUser)
|
||||
or isinstance(element, (str, six.text_type))
|
||||
isinstance(element, github.NamedUser.NamedUser) or isinstance(element, str)
|
||||
for element in assignees
|
||||
), assignees
|
||||
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, six.text_type))
|
||||
isinstance(element, github.Label.Label) or isinstance(element, str)
|
||||
for element in labels
|
||||
), labels
|
||||
|
||||
@@ -1153,7 +1145,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
if body is not github.GithubObject.NotSet:
|
||||
post_parameters["body"] = body
|
||||
if assignee is not github.GithubObject.NotSet:
|
||||
if isinstance(assignee, (str, six.text_type)):
|
||||
if isinstance(assignee, str):
|
||||
post_parameters["assignee"] = assignee
|
||||
else:
|
||||
post_parameters["assignee"] = assignee._identity
|
||||
@@ -1184,8 +1176,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param read_only: bool
|
||||
:rtype: :class:`github.RepositoryKey.RepositoryKey`
|
||||
"""
|
||||
assert isinstance(title, (str, six.text_type)), title
|
||||
assert isinstance(key, (str, six.text_type)), key
|
||||
assert isinstance(title, str), title
|
||||
assert isinstance(key, str), key
|
||||
assert isinstance(read_only, bool), read_only
|
||||
post_parameters = {
|
||||
"title": title,
|
||||
@@ -1207,10 +1199,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param description: string
|
||||
:rtype: :class:`github.Label.Label`
|
||||
"""
|
||||
assert isinstance(name, (str, six.text_type)), name
|
||||
assert isinstance(color, (str, six.text_type)), color
|
||||
assert isinstance(name, str), name
|
||||
assert isinstance(color, str), color
|
||||
assert description is github.GithubObject.NotSet or isinstance(
|
||||
description, (str, six.text_type)
|
||||
description, str
|
||||
), description
|
||||
post_parameters = {
|
||||
"name": name,
|
||||
@@ -1241,12 +1233,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param due_on: datetime
|
||||
:rtype: :class:`github.Milestone.Milestone`
|
||||
"""
|
||||
assert isinstance(title, (str, six.text_type)), title
|
||||
assert state is github.GithubObject.NotSet or isinstance(
|
||||
state, (str, six.text_type)
|
||||
), state
|
||||
assert isinstance(title, str), title
|
||||
assert state is github.GithubObject.NotSet or isinstance(state, str), state
|
||||
assert description is github.GithubObject.NotSet or isinstance(
|
||||
description, (str, six.text_type)
|
||||
description, str
|
||||
), description
|
||||
assert due_on is github.GithubObject.NotSet or isinstance(
|
||||
due_on, (datetime.datetime, datetime.date)
|
||||
@@ -1276,10 +1266,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param name: string
|
||||
:param body: string
|
||||
"""
|
||||
assert isinstance(name, (str, six.text_type)), name
|
||||
assert body is github.GithubObject.NotSet or isinstance(
|
||||
body, (str, six.text_type)
|
||||
), body
|
||||
assert isinstance(name, str), name
|
||||
assert body is github.GithubObject.NotSet or isinstance(body, str), body
|
||||
post_parameters = {
|
||||
"name": name,
|
||||
"body": body,
|
||||
@@ -1311,10 +1299,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
def __create_pull_1(
|
||||
self, title, body, base, head, maintainer_can_modify=github.GithubObject.NotSet
|
||||
):
|
||||
assert isinstance(title, (str, six.text_type)), title
|
||||
assert isinstance(body, (str, six.text_type)), body
|
||||
assert isinstance(base, (str, six.text_type)), base
|
||||
assert isinstance(head, (str, six.text_type)), head
|
||||
assert isinstance(title, str), title
|
||||
assert isinstance(body, str), body
|
||||
assert isinstance(base, str), base
|
||||
assert isinstance(head, str), head
|
||||
assert maintainer_can_modify is github.GithubObject.NotSet or isinstance(
|
||||
maintainer_can_modify, bool
|
||||
), maintainer_can_modify
|
||||
@@ -1331,8 +1319,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
def __create_pull_2(self, issue, base, head):
|
||||
assert isinstance(issue, github.Issue.Issue), issue
|
||||
assert isinstance(base, (str, six.text_type)), base
|
||||
assert isinstance(head, (str, six.text_type)), head
|
||||
assert isinstance(base, str), base
|
||||
assert isinstance(head, str), head
|
||||
return self.__create_pull(issue=issue._identity, base=base, head=head)
|
||||
|
||||
def __create_pull(self, **kwds):
|
||||
@@ -1359,13 +1347,13 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param vcs_password: string
|
||||
:rtype: :class:`github.SourceImport.SourceImport`
|
||||
"""
|
||||
assert isinstance(vcs, (str, six.text_type)), vcs
|
||||
assert isinstance(vcs_url, (str, six.text_type)), vcs_url
|
||||
assert isinstance(vcs, str), vcs
|
||||
assert isinstance(vcs_url, str), vcs_url
|
||||
assert vcs_username is github.GithubObject.NotSet or isinstance(
|
||||
vcs_username, (str, six.text_type)
|
||||
vcs_username, str
|
||||
), vcs_username
|
||||
assert vcs_password is github.GithubObject.NotSet or isinstance(
|
||||
vcs_password, (str, six.text_type)
|
||||
vcs_password, str
|
||||
), vcs_password
|
||||
put_parameters = {"vcs": vcs, "vcs_url": vcs_url}
|
||||
|
||||
@@ -1427,12 +1415,12 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
if name is None:
|
||||
name = self.name
|
||||
assert isinstance(name, (str, six.text_type)), name
|
||||
assert isinstance(name, str), name
|
||||
assert description is github.GithubObject.NotSet or isinstance(
|
||||
description, (str, six.text_type)
|
||||
description, str
|
||||
), description
|
||||
assert homepage is github.GithubObject.NotSet or isinstance(
|
||||
homepage, (str, six.text_type)
|
||||
homepage, str
|
||||
), homepage
|
||||
assert private is github.GithubObject.NotSet or isinstance(
|
||||
private, bool
|
||||
@@ -1450,7 +1438,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
has_downloads, bool
|
||||
), has_downloads
|
||||
assert default_branch is github.GithubObject.NotSet or isinstance(
|
||||
default_branch, (str, six.text_type)
|
||||
default_branch, str
|
||||
), default_branch
|
||||
assert allow_squash_merge is github.GithubObject.NotSet or isinstance(
|
||||
allow_squash_merge, bool
|
||||
@@ -1503,10 +1491,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param ref: string
|
||||
:rtype: string
|
||||
"""
|
||||
assert isinstance(archive_format, (str, six.text_type)), archive_format
|
||||
assert ref is github.GithubObject.NotSet or isinstance(
|
||||
ref, (str, six.text_type)
|
||||
), ref
|
||||
assert isinstance(archive_format, str), archive_format
|
||||
assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref
|
||||
url = self.url + "/" + archive_format
|
||||
if ref is not github.GithubObject.NotSet:
|
||||
url += "/" + ref
|
||||
@@ -1528,7 +1514,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param branch: string
|
||||
:rtype: :class:`github.Branch.Branch`
|
||||
"""
|
||||
assert isinstance(branch, (str, six.text_type)), branch
|
||||
assert isinstance(branch, str), branch
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/branches/" + branch
|
||||
)
|
||||
@@ -1572,7 +1558,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param id: integer
|
||||
:rtype: :class:`github.CommitComment.CommitComment`
|
||||
"""
|
||||
assert isinstance(id, six.integer_types), id
|
||||
assert isinstance(id, int), id
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/comments/" + str(id)
|
||||
)
|
||||
@@ -1598,7 +1584,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param sha: string
|
||||
:rtype: :class:`github.Commit.Commit`
|
||||
"""
|
||||
assert isinstance(sha, (str, six.text_type)), sha
|
||||
assert isinstance(sha, str), sha
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/commits/" + sha
|
||||
)
|
||||
@@ -1621,12 +1607,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param author: string or :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser`
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit.Commit`
|
||||
"""
|
||||
assert sha is github.GithubObject.NotSet or isinstance(
|
||||
sha, (str, six.text_type)
|
||||
), sha
|
||||
assert path is github.GithubObject.NotSet or isinstance(
|
||||
path, (str, six.text_type)
|
||||
), path
|
||||
assert sha is github.GithubObject.NotSet or isinstance(sha, str), sha
|
||||
assert path is github.GithubObject.NotSet or isinstance(path, str), path
|
||||
assert since is github.GithubObject.NotSet or isinstance(
|
||||
since, datetime.datetime
|
||||
), since
|
||||
@@ -1637,7 +1619,6 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
author,
|
||||
(
|
||||
str,
|
||||
six.text_type,
|
||||
github.NamedUser.NamedUser,
|
||||
github.AuthenticatedUser.AuthenticatedUser,
|
||||
),
|
||||
@@ -1673,10 +1654,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param ref: string
|
||||
:rtype: :class:`github.ContentFile.ContentFile` or a list of them
|
||||
"""
|
||||
assert isinstance(path, (str, six.text_type)), path
|
||||
assert ref is github.GithubObject.NotSet or isinstance(
|
||||
ref, (str, six.text_type)
|
||||
), ref
|
||||
assert isinstance(path, str), path
|
||||
assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref
|
||||
# Path of '/' should be the empty string.
|
||||
if path == "/":
|
||||
path = ""
|
||||
@@ -1685,7 +1664,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
url_parameters["ref"] = ref
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/contents/" + six.moves.urllib.parse.quote(path),
|
||||
self.url + "/contents/" + urllib.parse.quote(path),
|
||||
parameters=url_parameters,
|
||||
)
|
||||
|
||||
@@ -1743,7 +1722,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: None or list of :class:`github.View.View`
|
||||
"""
|
||||
assert per is github.GithubObject.NotSet or (
|
||||
isinstance(per, (str, six.text_type)) and (per == "day" or per == "week")
|
||||
isinstance(per, str) and (per == "day" or per == "week")
|
||||
), "per must be day or week, day by default"
|
||||
url_parameters = dict()
|
||||
if per is not github.GithubObject.NotSet:
|
||||
@@ -1769,7 +1748,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: None or list of :class:`github.Clone.Clone`
|
||||
"""
|
||||
assert per is github.GithubObject.NotSet or (
|
||||
isinstance(per, (str, six.text_type)) and (per == "day" or per == "week")
|
||||
isinstance(per, str) and (per == "day" or per == "week")
|
||||
), "per must be day or week, day by default"
|
||||
url_parameters = dict()
|
||||
if per is not github.GithubObject.NotSet:
|
||||
@@ -1829,22 +1808,16 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
'content': :class:`ContentFile <github.ContentFile.ContentFile>`:,
|
||||
'commit': :class:`Commit <github.Commit.Commit>`}
|
||||
"""
|
||||
assert isinstance(path, (str, six.text_type)), "path must be str/unicode object"
|
||||
assert isinstance(
|
||||
message, (str, six.text_type)
|
||||
), "message must be str/unicode object"
|
||||
assert isinstance(
|
||||
content, (str, six.text_type, bytes)
|
||||
), "content must be a str/unicode object"
|
||||
assert branch is github.GithubObject.NotSet or isinstance(
|
||||
branch, (str, six.text_type)
|
||||
), "branch must be a str/unicode object"
|
||||
assert isinstance(path, str)
|
||||
assert isinstance(message, str)
|
||||
assert isinstance(content, (str, bytes))
|
||||
assert branch is github.GithubObject.NotSet or isinstance(branch, str)
|
||||
assert author is github.GithubObject.NotSet or isinstance(
|
||||
author, github.InputGitAuthor
|
||||
), "author must be a github.InputGitAuthor object"
|
||||
)
|
||||
assert committer is github.GithubObject.NotSet or isinstance(
|
||||
committer, github.InputGitAuthor
|
||||
), "committer must be a github.InputGitAuthor object"
|
||||
)
|
||||
|
||||
if not isinstance(content, bytes):
|
||||
content = content.encode("utf-8")
|
||||
@@ -1860,7 +1833,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/contents/" + six.moves.urllib.parse.quote(path),
|
||||
self.url + "/contents/" + urllib.parse.quote(path),
|
||||
input=put_parameters,
|
||||
)
|
||||
|
||||
@@ -1897,23 +1870,17 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
'content': :class:`ContentFile <github.ContentFile.ContentFile>`:,
|
||||
'commit': :class:`Commit <github.Commit.Commit>`}
|
||||
"""
|
||||
assert isinstance(path, (str, six.text_type)), "path must be str/unicode object"
|
||||
assert isinstance(
|
||||
message, (str, six.text_type)
|
||||
), "message must be str/unicode object"
|
||||
assert isinstance(
|
||||
content, (str, six.text_type, bytes)
|
||||
), "content must be a str/unicode object"
|
||||
assert isinstance(sha, (str, six.text_type)), "sha must be a str/unicode object"
|
||||
assert branch is github.GithubObject.NotSet or isinstance(
|
||||
branch, (str, six.text_type)
|
||||
), "branch must be a str/unicode object"
|
||||
assert isinstance(path, str)
|
||||
assert isinstance(message, str)
|
||||
assert isinstance(content, (str, bytes))
|
||||
assert isinstance(sha, str)
|
||||
assert branch is github.GithubObject.NotSet or isinstance(branch, str)
|
||||
assert author is github.GithubObject.NotSet or isinstance(
|
||||
author, github.InputGitAuthor
|
||||
), "author must be a github.InputGitAuthor object"
|
||||
)
|
||||
assert committer is github.GithubObject.NotSet or isinstance(
|
||||
committer, github.InputGitAuthor
|
||||
), "committer must be a github.InputGitAuthor object"
|
||||
)
|
||||
|
||||
if not isinstance(content, bytes):
|
||||
content = content.encode("utf-8")
|
||||
@@ -1930,7 +1897,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT",
|
||||
self.url + "/contents/" + six.moves.urllib.parse.quote(path),
|
||||
self.url + "/contents/" + urllib.parse.quote(path),
|
||||
input=put_parameters,
|
||||
)
|
||||
|
||||
@@ -1965,13 +1932,11 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
'content': :class:`null <github.GithubObject.NotSet>`:,
|
||||
'commit': :class:`Commit <github.Commit.Commit>`}
|
||||
"""
|
||||
assert isinstance(path, (str, six.text_type)), "path must be str/unicode object"
|
||||
assert isinstance(
|
||||
message, (str, six.text_type)
|
||||
), "message must be str/unicode object"
|
||||
assert isinstance(sha, (str, six.text_type)), "sha must be a str/unicode object"
|
||||
assert isinstance(path, str), "path must be str/unicode object"
|
||||
assert isinstance(message, str), "message must be str/unicode object"
|
||||
assert isinstance(sha, str), "sha must be a str/unicode object"
|
||||
assert branch is github.GithubObject.NotSet or isinstance(
|
||||
branch, (str, six.text_type)
|
||||
branch, str
|
||||
), "branch must be a str/unicode object"
|
||||
assert author is github.GithubObject.NotSet or isinstance(
|
||||
author, github.InputGitAuthor
|
||||
@@ -1990,7 +1955,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE",
|
||||
self.url + "/contents/" + six.moves.urllib.parse.quote(path),
|
||||
self.url + "/contents/" + urllib.parse.quote(path),
|
||||
input=url_parameters,
|
||||
)
|
||||
|
||||
@@ -2039,7 +2004,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param id: integer
|
||||
:rtype: :class:`github.Download.Download`
|
||||
"""
|
||||
assert isinstance(id, six.integer_types), id
|
||||
assert isinstance(id, int), id
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/downloads/" + str(id)
|
||||
)
|
||||
@@ -2079,7 +2044,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: :class:`github.Repository.Repository`
|
||||
"""
|
||||
assert organization is github.GithubObject.NotSet or isinstance(
|
||||
organization, (str, six.text_type)
|
||||
organization, str
|
||||
), organization
|
||||
post_parameters = {}
|
||||
if organization is not None:
|
||||
@@ -2095,7 +2060,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param sha: string
|
||||
:rtype: :class:`github.GitBlob.GitBlob`
|
||||
"""
|
||||
assert isinstance(sha, (str, six.text_type)), sha
|
||||
assert isinstance(sha, str), sha
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/git/blobs/" + sha
|
||||
)
|
||||
@@ -2107,7 +2072,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param sha: string
|
||||
:rtype: :class:`github.GitCommit.GitCommit`
|
||||
"""
|
||||
assert isinstance(sha, (str, six.text_type)), sha
|
||||
assert isinstance(sha, str), sha
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/git/commits/" + sha
|
||||
)
|
||||
@@ -2124,7 +2089,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
prefix = "/git/refs/"
|
||||
if not self._requester.FIX_REPO_GET_GIT_REF:
|
||||
prefix = "/git/"
|
||||
assert isinstance(ref, (str, six.text_type)), ref
|
||||
assert isinstance(ref, str), ref
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + prefix + ref
|
||||
)
|
||||
@@ -2145,7 +2110,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param sha: string
|
||||
:rtype: :class:`github.GitTag.GitTag`
|
||||
"""
|
||||
assert isinstance(sha, (str, six.text_type)), sha
|
||||
assert isinstance(sha, str), sha
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/git/tags/" + sha
|
||||
)
|
||||
@@ -2158,7 +2123,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param recursive: bool
|
||||
:rtype: :class:`github.GitTree.GitTree`
|
||||
"""
|
||||
assert isinstance(sha, (str, six.text_type)), sha
|
||||
assert isinstance(sha, str), sha
|
||||
assert recursive is github.GithubObject.NotSet or isinstance(
|
||||
recursive, bool
|
||||
), recursive
|
||||
@@ -2177,7 +2142,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param id: integer
|
||||
:rtype: :class:`github.Hook.Hook`
|
||||
"""
|
||||
assert isinstance(id, six.integer_types), id
|
||||
assert isinstance(id, int), id
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/hooks/" + str(id)
|
||||
)
|
||||
@@ -2198,7 +2163,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param number: integer
|
||||
:rtype: :class:`github.Issue.Issue`
|
||||
"""
|
||||
assert isinstance(number, six.integer_types), number
|
||||
assert isinstance(number, int), number
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/issues/" + str(number)
|
||||
)
|
||||
@@ -2235,13 +2200,11 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
or milestone == "none"
|
||||
or isinstance(milestone, github.Milestone.Milestone)
|
||||
), milestone
|
||||
assert state is github.GithubObject.NotSet or isinstance(
|
||||
state, (str, six.text_type)
|
||||
), state
|
||||
assert state is github.GithubObject.NotSet or isinstance(state, str), state
|
||||
assert (
|
||||
assignee is github.GithubObject.NotSet
|
||||
or isinstance(assignee, github.NamedUser.NamedUser)
|
||||
or isinstance(assignee, (str, six.text_type))
|
||||
or isinstance(assignee, str)
|
||||
), assignee
|
||||
assert mentioned is github.GithubObject.NotSet or isinstance(
|
||||
mentioned, github.NamedUser.NamedUser
|
||||
@@ -2249,11 +2212,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
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, six.text_type)
|
||||
), sort
|
||||
assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort
|
||||
assert direction is github.GithubObject.NotSet or isinstance(
|
||||
direction, (str, six.text_type)
|
||||
direction, str
|
||||
), direction
|
||||
assert since is github.GithubObject.NotSet or isinstance(
|
||||
since, datetime.datetime
|
||||
@@ -2261,18 +2222,18 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
assert (
|
||||
creator is github.GithubObject.NotSet
|
||||
or isinstance(creator, github.NamedUser.NamedUser)
|
||||
or isinstance(creator, (str, six.text_type))
|
||||
or isinstance(creator, str)
|
||||
), creator
|
||||
url_parameters = dict()
|
||||
if milestone is not github.GithubObject.NotSet:
|
||||
if isinstance(milestone, (str, six.text_type)):
|
||||
if isinstance(milestone, str):
|
||||
url_parameters["milestone"] = milestone
|
||||
else:
|
||||
url_parameters["milestone"] = milestone._identity
|
||||
if state is not github.GithubObject.NotSet:
|
||||
url_parameters["state"] = state
|
||||
if assignee is not github.GithubObject.NotSet:
|
||||
if isinstance(assignee, (str, six.text_type)):
|
||||
if isinstance(assignee, str):
|
||||
url_parameters["assignee"] = assignee
|
||||
else:
|
||||
url_parameters["assignee"] = assignee._identity
|
||||
@@ -2287,7 +2248,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
if since is not github.GithubObject.NotSet:
|
||||
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
if creator is not github.GithubObject.NotSet:
|
||||
if isinstance(creator, (str, six.text_type)):
|
||||
if isinstance(creator, str):
|
||||
url_parameters["creator"] = creator
|
||||
else:
|
||||
url_parameters["creator"] = creator._identity
|
||||
@@ -2308,11 +2269,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param since: datetime.datetime
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.IssueComment.IssueComment`
|
||||
"""
|
||||
assert sort is github.GithubObject.NotSet or isinstance(
|
||||
sort, (str, six.text_type)
|
||||
), sort
|
||||
assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort
|
||||
assert direction is github.GithubObject.NotSet or isinstance(
|
||||
direction, (str, six.text_type)
|
||||
direction, str
|
||||
), direction
|
||||
assert since is github.GithubObject.NotSet or isinstance(
|
||||
since, datetime.datetime
|
||||
@@ -2337,7 +2296,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param id: integer
|
||||
:rtype: :class:`github.IssueEvent.IssueEvent`
|
||||
"""
|
||||
assert isinstance(id, six.integer_types), id
|
||||
assert isinstance(id, int), id
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
self.url + "/issues/events/" + str(id),
|
||||
@@ -2366,7 +2325,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param id: integer
|
||||
:rtype: :class:`github.RepositoryKey.RepositoryKey`
|
||||
"""
|
||||
assert isinstance(id, six.integer_types), id
|
||||
assert isinstance(id, int), id
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/keys/" + str(id)
|
||||
)
|
||||
@@ -2392,9 +2351,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param name: string
|
||||
:rtype: :class:`github.Label.Label`
|
||||
"""
|
||||
assert isinstance(name, (str, six.text_type)), name
|
||||
assert isinstance(name, str), name
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/labels/" + six.moves.urllib.parse.quote(name)
|
||||
"GET", self.url + "/labels/" + urllib.parse.quote(name)
|
||||
)
|
||||
return github.Label.Label(self._requester, headers, data, completed=True)
|
||||
|
||||
@@ -2436,7 +2395,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param number: integer
|
||||
:rtype: :class:`github.Milestone.Milestone`
|
||||
"""
|
||||
assert isinstance(number, six.integer_types), number
|
||||
assert isinstance(number, int), number
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/milestones/" + str(number)
|
||||
)
|
||||
@@ -2457,14 +2416,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param direction: string
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Milestone.Milestone`
|
||||
"""
|
||||
assert state is github.GithubObject.NotSet or isinstance(
|
||||
state, (str, six.text_type)
|
||||
), state
|
||||
assert sort is github.GithubObject.NotSet or isinstance(
|
||||
sort, (str, six.text_type)
|
||||
), sort
|
||||
assert state is github.GithubObject.NotSet or isinstance(state, str), state
|
||||
assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort
|
||||
assert direction is github.GithubObject.NotSet or isinstance(
|
||||
direction, (str, six.text_type)
|
||||
direction, str
|
||||
), direction
|
||||
url_parameters = dict()
|
||||
if state is not github.GithubObject.NotSet:
|
||||
@@ -2498,7 +2453,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param number: integer
|
||||
:rtype: :class:`github.PullRequest.PullRequest`
|
||||
"""
|
||||
assert isinstance(number, six.integer_types), number
|
||||
assert isinstance(number, int), number
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/pulls/" + str(number)
|
||||
)
|
||||
@@ -2523,21 +2478,13 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param head: string
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequest.PullRequest`
|
||||
"""
|
||||
assert state is github.GithubObject.NotSet or isinstance(
|
||||
state, (str, six.text_type)
|
||||
), state
|
||||
assert sort is github.GithubObject.NotSet or isinstance(
|
||||
sort, (str, six.text_type)
|
||||
), sort
|
||||
assert state is github.GithubObject.NotSet or isinstance(state, str), state
|
||||
assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort
|
||||
assert direction is github.GithubObject.NotSet or isinstance(
|
||||
direction, (str, six.text_type)
|
||||
direction, str
|
||||
), direction
|
||||
assert base is github.GithubObject.NotSet or isinstance(
|
||||
base, (str, six.text_type)
|
||||
), base
|
||||
assert head is github.GithubObject.NotSet or isinstance(
|
||||
head, (str, six.text_type)
|
||||
), head
|
||||
assert base is github.GithubObject.NotSet or isinstance(base, str), base
|
||||
assert head is github.GithubObject.NotSet or isinstance(head, str), head
|
||||
url_parameters = dict()
|
||||
if state is not github.GithubObject.NotSet:
|
||||
url_parameters["state"] = state
|
||||
@@ -2584,11 +2531,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param since: datetime.datetime
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.PullRequestComment.PullRequestComment`
|
||||
"""
|
||||
assert sort is github.GithubObject.NotSet or isinstance(
|
||||
sort, (str, six.text_type)
|
||||
), sort
|
||||
assert sort is github.GithubObject.NotSet or isinstance(sort, str), sort
|
||||
assert direction is github.GithubObject.NotSet or isinstance(
|
||||
direction, (str, six.text_type)
|
||||
direction, str
|
||||
), direction
|
||||
assert since is github.GithubObject.NotSet or isinstance(
|
||||
since, datetime.datetime
|
||||
@@ -2613,9 +2558,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param ref: string
|
||||
:rtype: :class:`github.ContentFile.ContentFile`
|
||||
"""
|
||||
assert ref is github.GithubObject.NotSet or isinstance(
|
||||
ref, (str, six.text_type)
|
||||
), ref
|
||||
assert ref is github.GithubObject.NotSet or isinstance(ref, str), ref
|
||||
url_parameters = dict()
|
||||
if ref is not github.GithubObject.NotSet:
|
||||
url_parameters["ref"] = ref
|
||||
@@ -2788,7 +2731,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
return github.GitRelease.GitRelease(
|
||||
self._requester, headers, data, completed=True
|
||||
)
|
||||
elif isinstance(id, (str, six.text_type)):
|
||||
elif isinstance(id, str):
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/releases/tags/" + id
|
||||
)
|
||||
@@ -2845,7 +2788,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance(
|
||||
assignee, (str, six.text_type)
|
||||
assignee, str
|
||||
), assignee
|
||||
|
||||
if isinstance(assignee, github.NamedUser.NamedUser):
|
||||
@@ -2863,7 +2806,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: bool
|
||||
"""
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(
|
||||
collaborator, (str, six.text_type)
|
||||
collaborator, str
|
||||
), collaborator
|
||||
|
||||
if isinstance(collaborator, github.NamedUser.NamedUser):
|
||||
@@ -2877,8 +2820,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
def _legacy_convert_issue(self, attributes):
|
||||
convertedAttributes = {
|
||||
"number": attributes["number"],
|
||||
"url": "/repos"
|
||||
+ six.moves.urllib.parse.urlparse(attributes["html_url"]).path,
|
||||
"url": "/repos" + urllib.parse.urlparse(attributes["html_url"]).path,
|
||||
"user": {
|
||||
"login": attributes["user"],
|
||||
"url": "/users/" + attributes["user"],
|
||||
@@ -2901,7 +2843,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue`
|
||||
"""
|
||||
assert state in ["open", "closed"], state
|
||||
assert isinstance(keyword, (str, six.text_type)), keyword
|
||||
assert isinstance(keyword, str), keyword
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET",
|
||||
"/legacy/issues/search/"
|
||||
@@ -2911,7 +2853,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
+ "/"
|
||||
+ state
|
||||
+ "/"
|
||||
+ six.moves.urllib.parse.quote(keyword),
|
||||
+ urllib.parse.quote(keyword),
|
||||
)
|
||||
return [
|
||||
github.Issue.Issue(
|
||||
@@ -2987,10 +2929,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:param commit_message: string
|
||||
:rtype: :class:`github.Commit.Commit`
|
||||
"""
|
||||
assert isinstance(base, (str, six.text_type)), base
|
||||
assert isinstance(head, (str, six.text_type)), head
|
||||
assert isinstance(base, str), base
|
||||
assert isinstance(head, str), head
|
||||
assert commit_message is github.GithubObject.NotSet or isinstance(
|
||||
commit_message, (str, six.text_type)
|
||||
commit_message, str
|
||||
), commit_message
|
||||
post_parameters = {
|
||||
"base": base,
|
||||
@@ -3087,7 +3029,7 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: None
|
||||
"""
|
||||
assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(
|
||||
collaborator, (str, six.text_type)
|
||||
collaborator, str
|
||||
), collaborator
|
||||
|
||||
if isinstance(collaborator, github.NamedUser.NamedUser):
|
||||
@@ -3118,12 +3060,10 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
return self._hub("unsubscribe", event, callback, github.GithubObject.NotSet)
|
||||
|
||||
def _hub(self, mode, event, callback, secret):
|
||||
assert isinstance(mode, (str, six.text_type)), mode
|
||||
assert isinstance(event, (str, six.text_type)), event
|
||||
assert isinstance(callback, (str, six.text_type)), callback
|
||||
assert secret is github.GithubObject.NotSet or isinstance(
|
||||
secret, (str, six.text_type)
|
||||
), secret
|
||||
assert isinstance(mode, str), mode
|
||||
assert isinstance(event, str), event
|
||||
assert isinstance(callback, str), callback
|
||||
assert secret is github.GithubObject.NotSet or isinstance(secret, str), secret
|
||||
|
||||
post_parameters = collections.OrderedDict()
|
||||
post_parameters["hub.callback"] = callback
|
||||
|
||||
Reference in New Issue
Block a user