mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Format with new black (#1679)
Black is very opinionated, but sometimes those opinions change. Run the new black version across the codebase, and lock down the version used by pre-commit so we don't get surprised like this again.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: stable
|
||||
rev: 20.8b1
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.6
|
||||
|
||||
@@ -479,7 +479,10 @@ class AuthenticatedUser(github.GithubObject.CompletableGithubObject):
|
||||
else:
|
||||
request_header = None
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST", "/authorizations", input=post_parameters, headers=request_header,
|
||||
"POST",
|
||||
"/authorizations",
|
||||
input=post_parameters,
|
||||
headers=request_header,
|
||||
)
|
||||
return github.Authorization.Authorization(
|
||||
self._requester, headers, data, completed=True
|
||||
|
||||
+4
-3
@@ -163,7 +163,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
|
||||
assert (
|
||||
required_approving_review_count is github.GithubObject.NotSet
|
||||
or isinstance(required_approving_review_count, int)
|
||||
), required_approving_review_count
|
||||
), (required_approving_review_count)
|
||||
|
||||
post_parameters = {}
|
||||
if (
|
||||
@@ -250,7 +250,8 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
|
||||
:calls: `DELETE /repos/:owner/:repo/branches/:branch/protection <https://developer.github.com/v3/repos/branches>`_
|
||||
"""
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE", self.protection_url,
|
||||
"DELETE",
|
||||
self.protection_url,
|
||||
)
|
||||
|
||||
def get_required_status_checks(self):
|
||||
@@ -342,7 +343,7 @@ class Branch(github.GithubObject.NonCompletableGithubObject):
|
||||
assert (
|
||||
required_approving_review_count is github.GithubObject.NotSet
|
||||
or isinstance(required_approving_review_count, int)
|
||||
), required_approving_review_count
|
||||
), (required_approving_review_count)
|
||||
|
||||
post_parameters = {}
|
||||
if dismissal_users is not github.GithubObject.NotSet:
|
||||
|
||||
@@ -194,7 +194,9 @@ class Deployment(github.GithubObject.CompletableGithubObject):
|
||||
if description is not github.GithubObject.NotSet:
|
||||
post_parameters["description"] = description
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST", self.url + "/statuses", input=post_parameters,
|
||||
"POST",
|
||||
self.url + "/statuses",
|
||||
input=post_parameters,
|
||||
)
|
||||
return github.DeploymentStatus.DeploymentStatus(
|
||||
self._requester, headers, data, completed=True
|
||||
|
||||
@@ -118,7 +118,10 @@ class Notification(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
:calls: `PATCH /notifications/threads/:id <https://developer.github.com/v3/activity/notifications/>`_
|
||||
"""
|
||||
headers, data = self._requester.requestJsonAndCheck("PATCH", self.url,)
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PATCH",
|
||||
self.url,
|
||||
)
|
||||
|
||||
def get_pull_request(self):
|
||||
"""
|
||||
|
||||
@@ -168,7 +168,9 @@ class ProjectCard(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: bool
|
||||
"""
|
||||
status, _, _ = self._requester.requestJson(
|
||||
"DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview},
|
||||
"DELETE",
|
||||
self.url,
|
||||
headers={"Accept": Consts.mediaTypeProjectsPreview},
|
||||
)
|
||||
return status == 204
|
||||
|
||||
|
||||
@@ -170,7 +170,9 @@ class ProjectColumn(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: bool
|
||||
"""
|
||||
status, _, _ = self._requester.requestJson(
|
||||
"DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview},
|
||||
"DELETE",
|
||||
self.url,
|
||||
headers={"Accept": Consts.mediaTypeProjectsPreview},
|
||||
)
|
||||
return status == 204
|
||||
|
||||
|
||||
@@ -713,7 +713,8 @@ class PullRequest(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
assert isinstance(id, int), id
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/reviews/" + str(id),
|
||||
"GET",
|
||||
self.url + "/reviews/" + str(id),
|
||||
)
|
||||
return github.PullRequestReview.PullRequestReview(
|
||||
self._requester, headers, data, completed=True
|
||||
|
||||
+11
-4
@@ -844,7 +844,8 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
if isinstance(collaborator, github.NamedUser.NamedUser):
|
||||
collaborator = collaborator._identity
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/collaborators/" + collaborator + "/permission",
|
||||
"GET",
|
||||
self.url + "/collaborators/" + collaborator + "/permission",
|
||||
)
|
||||
return data["permission"]
|
||||
|
||||
@@ -1876,7 +1877,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
if description is not github.GithubObject.NotSet:
|
||||
post_parameters["description"] = description
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST", self.url + "/deployments", input=post_parameters,
|
||||
"POST",
|
||||
self.url + "/deployments",
|
||||
input=post_parameters,
|
||||
)
|
||||
return github.Deployment.Deployment(
|
||||
self._requester, headers, data, completed=True
|
||||
@@ -2245,7 +2248,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
if organization is not github.GithubObject.NotSet:
|
||||
post_parameters["organization"] = organization
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"POST", self.url + "/forks", input=post_parameters,
|
||||
"POST",
|
||||
self.url + "/forks",
|
||||
input=post_parameters,
|
||||
)
|
||||
return Repository(self._requester, headers, data, completed=True)
|
||||
|
||||
@@ -2790,7 +2795,9 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
import_header = {"Accept": Consts.mediaTypeImportPreview}
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", self.url + "/import", headers=import_header,
|
||||
"GET",
|
||||
self.url + "/import",
|
||||
headers=import_header,
|
||||
)
|
||||
if not data:
|
||||
return None
|
||||
|
||||
+4
-1
@@ -319,7 +319,10 @@ class Team(github.GithubObject.CompletableGithubObject):
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Team.Team`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.Team.Team, self._requester, self.url + "/teams", None,
|
||||
github.Team.Team,
|
||||
self._requester,
|
||||
self.url + "/teams",
|
||||
None,
|
||||
)
|
||||
|
||||
def get_discussions(self):
|
||||
|
||||
+2
-1
@@ -85,7 +85,8 @@ class Commit(Framework.TestCase):
|
||||
self.commit.commit.tree.sha, "4c6bd50994f0f9823f898b1c6c964ad7d4fa11ab"
|
||||
)
|
||||
self.assertEqual(
|
||||
repr(self.commit), 'Commit(sha="1292bf0e22c796e91cc3d6e24b544aece8c21f2a")',
|
||||
repr(self.commit),
|
||||
'Commit(sha="1292bf0e22c796e91cc3d6e24b544aece8c21f2a")',
|
||||
)
|
||||
|
||||
def testGetComments(self):
|
||||
|
||||
@@ -58,7 +58,8 @@ class DeploymentStatus(Framework.TestCase):
|
||||
"https://api.github.com/repos/colbygallup/PyGithub/deployments/242997115/statuses/344110026",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.status.node_id, "MDE2OkRlcGxveW1lbnRTdGF0dXMzNDQxMTAwMjY=",
|
||||
self.status.node_id,
|
||||
"MDE2OkRlcGxveW1lbnRTdGF0dXMzNDQxMTAwMjY=",
|
||||
)
|
||||
self.assertEqual(
|
||||
repr(self.status),
|
||||
|
||||
+2
-1
@@ -61,5 +61,6 @@ class GitBlob(Framework.TestCase):
|
||||
"https://api.github.com/repos/jacquev6/PyGithub/git/blobs/53bce9fa919b4544e67275089b3ec5b44be20667",
|
||||
)
|
||||
self.assertEqual(
|
||||
repr(self.blob), 'GitBlob(sha="53bce9fa919b4544e67275089b3ec5b44be20667")',
|
||||
repr(self.blob),
|
||||
'GitBlob(sha="53bce9fa919b4544e67275089b3ec5b44be20667")',
|
||||
)
|
||||
|
||||
+2
-1
@@ -72,7 +72,8 @@ class GitTree(Framework.TestCase):
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
repr(self.tree), 'GitTree(sha="f492784d8ca837779650d1fb406a1a3587a764ad")',
|
||||
repr(self.tree),
|
||||
'GitTree(sha="f492784d8ca837779650d1fb406a1a3587a764ad")',
|
||||
)
|
||||
self.assertEqual(
|
||||
repr(self.tree.tree[0]),
|
||||
|
||||
+2
-1
@@ -110,7 +110,8 @@ class GithubApp(Framework.TestCase):
|
||||
self.assertEqual(app.created_at, datetime(2020, 8, 1, 17, 23, 46))
|
||||
self.assertEqual(app.description, "Sample App to test PyGithub")
|
||||
self.assertListEqual(
|
||||
app.events, ["check_run", "check_suite", "label", "member", "public"],
|
||||
app.events,
|
||||
["check_run", "check_suite", "label", "member", "public"],
|
||||
)
|
||||
self.assertEqual(app.external_url, "https://pygithub.readthedocs.io")
|
||||
self.assertEqual(app.html_url, "https://github.com/apps/pygithubtest")
|
||||
|
||||
@@ -135,7 +135,10 @@ class GithubIntegration(unittest.TestCase):
|
||||
integration = GithubIntegration(25216, private_key)
|
||||
token = integration.create_jwt()
|
||||
payload = jwt.decode(
|
||||
token, key=public_key, algorithms=["RS256"], options={"verify_exp": False},
|
||||
token,
|
||||
key=public_key,
|
||||
algorithms=["RS256"],
|
||||
options={"verify_exp": False},
|
||||
)
|
||||
self.assertDictEqual(
|
||||
payload, {"iat": 1550055331, "exp": 1550055391, "iss": 25216}
|
||||
|
||||
@@ -32,5 +32,7 @@ class NamedUser1430(Framework.TestCase):
|
||||
|
||||
def testGetProjects(self):
|
||||
self.assertListKeyBegin(
|
||||
self.user.get_projects(state="all"), lambda e: e.id, [4083095],
|
||||
self.user.get_projects(state="all"),
|
||||
lambda e: e.id,
|
||||
[4083095],
|
||||
)
|
||||
|
||||
@@ -239,10 +239,14 @@ class Organization(Framework.TestCase):
|
||||
def testGetReposSorted(self):
|
||||
repos = self.org.get_repos(sort="updated", direction="desc")
|
||||
self.assertListKeyEqual(
|
||||
repos, lambda r: r.name, ["TestPyGithub", "FatherBeaver"],
|
||||
repos,
|
||||
lambda r: r.name,
|
||||
["TestPyGithub", "FatherBeaver"],
|
||||
)
|
||||
self.assertListKeyEqual(
|
||||
repos, lambda r: r.has_pages, [False, True],
|
||||
repos,
|
||||
lambda r: r.has_pages,
|
||||
[False, True],
|
||||
)
|
||||
|
||||
def testGetReposWithType(self):
|
||||
|
||||
+9
-3
@@ -171,14 +171,18 @@ class Project(Framework.TestCase):
|
||||
project = self.repo.create_project(
|
||||
"Project created by PyGithub", "Project Body"
|
||||
)
|
||||
column = project.create_column("Project Column created by PyGithub",)
|
||||
column = project.create_column(
|
||||
"Project Column created by PyGithub",
|
||||
)
|
||||
self.assertEqual(column.id, 3999333)
|
||||
|
||||
def testCreateCardWithNote(self):
|
||||
project = self.repo.create_project(
|
||||
"Project created by PyGithub", "Project Body"
|
||||
)
|
||||
column = project.create_column("Project Column created by PyGithub",)
|
||||
column = project.create_column(
|
||||
"Project Column created by PyGithub",
|
||||
)
|
||||
card1 = column.create_card(note="Project Card")
|
||||
self.assertEqual(card1.id, 16039019)
|
||||
|
||||
@@ -186,7 +190,9 @@ class Project(Framework.TestCase):
|
||||
project = self.repo.create_project(
|
||||
"Project created by PyGithub", "Project Body"
|
||||
)
|
||||
column = project.create_column("Project Column created by PyGithub",)
|
||||
column = project.create_column(
|
||||
"Project Column created by PyGithub",
|
||||
)
|
||||
issue = self.repo.create_issue(title="Issue created by PyGithub")
|
||||
card2 = column.create_card(content_id=issue.id, content_type="Issue")
|
||||
self.assertEqual(card2.id, 16039106)
|
||||
|
||||
@@ -139,7 +139,8 @@ class PullRequest(Framework.TestCase):
|
||||
self.assertEqual(self.pull.draft, None)
|
||||
self.assertEqual(self.pull.maintainer_can_modify, None)
|
||||
self.assertEqual(
|
||||
repr(self.pull), 'PullRequest(title="Title edited by PyGithub", number=31)',
|
||||
repr(self.pull),
|
||||
'PullRequest(title="Title edited by PyGithub", number=31)',
|
||||
)
|
||||
self.assertEqual(
|
||||
repr(self.pull.base),
|
||||
|
||||
+8
-1
@@ -300,7 +300,14 @@ class Repository(Framework.TestCase):
|
||||
|
||||
def testCreateGitTreeWithNullSha(self):
|
||||
tree = self.repo.create_git_tree(
|
||||
[github.InputGitTreeElement("Baz.bar", "100644", "blob", sha=None,)]
|
||||
[
|
||||
github.InputGitTreeElement(
|
||||
"Baz.bar",
|
||||
"100644",
|
||||
"blob",
|
||||
sha=None,
|
||||
)
|
||||
]
|
||||
)
|
||||
self.assertEqual(tree.sha, "9b8166fc80d0f0fe9192d4bf1dbaa87f194e012f")
|
||||
|
||||
|
||||
+2
-1
@@ -47,7 +47,8 @@ class UserKey(Framework.TestCase):
|
||||
self.assertEqual(self.key.url, "https://api.github.com/user/keys/2626650")
|
||||
self.assertTrue(self.key.verified)
|
||||
self.assertEqual(
|
||||
repr(self.key), 'UserKey(title="Key added through PyGithub", id=2626650)',
|
||||
repr(self.key),
|
||||
'UserKey(title="Key added through PyGithub", id=2626650)',
|
||||
)
|
||||
|
||||
def testDelete(self):
|
||||
|
||||
Reference in New Issue
Block a user