Skip to content

Commit

Permalink
Format with new black (#1679)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
s-t-e-v-e-n-k committed Sep 2, 2020
1 parent 6bc9ecc commit 07e29fe
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: stable
rev: 20.8b1
hooks:
- id: black
language_version: python3.6
Expand Down
5 changes: 4 additions & 1 deletion github/AuthenticatedUser.py
Expand Up @@ -479,7 +479,10 @@ def create_authorization(
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
Expand Down
7 changes: 4 additions & 3 deletions github/Branch.py
Expand Up @@ -163,7 +163,7 @@ def edit_protection(
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 (
Expand Down Expand Up @@ -250,7 +250,8 @@ def remove_protection(self):
: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):
Expand Down Expand Up @@ -342,7 +343,7 @@ def edit_required_pull_request_reviews(
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:
Expand Down
4 changes: 3 additions & 1 deletion github/Deployment.py
Expand Up @@ -194,7 +194,9 @@ def create_status(
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
Expand Down
5 changes: 4 additions & 1 deletion github/Notification.py
Expand Up @@ -118,7 +118,10 @@ def mark_as_read(self):
"""
: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):
"""
Expand Down
4 changes: 3 additions & 1 deletion github/ProjectCard.py
Expand Up @@ -168,7 +168,9 @@ def delete(self):
:rtype: bool
"""
status, _, _ = self._requester.requestJson(
"DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview},
"DELETE",
self.url,
headers={"Accept": Consts.mediaTypeProjectsPreview},
)
return status == 204

Expand Down
4 changes: 3 additions & 1 deletion github/ProjectColumn.py
Expand Up @@ -170,7 +170,9 @@ def delete(self):
:rtype: bool
"""
status, _, _ = self._requester.requestJson(
"DELETE", self.url, headers={"Accept": Consts.mediaTypeProjectsPreview},
"DELETE",
self.url,
headers={"Accept": Consts.mediaTypeProjectsPreview},
)
return status == 204

Expand Down
3 changes: 2 additions & 1 deletion github/PullRequest.py
Expand Up @@ -713,7 +713,8 @@ def get_review(self, id):
"""
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
Expand Down
15 changes: 11 additions & 4 deletions github/Repository.py
Expand Up @@ -844,7 +844,8 @@ def get_collaborator_permission(self, collaborator):
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"]

Expand Down Expand Up @@ -1876,7 +1877,9 @@ def create_deployment(
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
Expand Down Expand Up @@ -2245,7 +2248,9 @@ def create_fork(self, organization=github.GithubObject.NotSet):
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)

Expand Down Expand Up @@ -2790,7 +2795,9 @@ def get_source_import(self):
"""
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
Expand Down
5 changes: 4 additions & 1 deletion github/Team.py
Expand Up @@ -319,7 +319,10 @@ def get_teams(self):
: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):
Expand Down
3 changes: 2 additions & 1 deletion tests/Commit.py
Expand Up @@ -85,7 +85,8 @@ def testAttributes(self):
self.commit.commit.tree.sha, "4c6bd50994f0f9823f898b1c6c964ad7d4fa11ab"
)
self.assertEqual(
repr(self.commit), 'Commit(sha="1292bf0e22c796e91cc3d6e24b544aece8c21f2a")',
repr(self.commit),
'Commit(sha="1292bf0e22c796e91cc3d6e24b544aece8c21f2a")',
)

def testGetComments(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/DeploymentStatus.py
Expand Up @@ -58,7 +58,8 @@ def testAttributes(self):
"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),
Expand Down
3 changes: 2 additions & 1 deletion tests/GitBlob.py
Expand Up @@ -61,5 +61,6 @@ def testAttributes(self):
"https://api.github.com/repos/jacquev6/PyGithub/git/blobs/53bce9fa919b4544e67275089b3ec5b44be20667",
)
self.assertEqual(
repr(self.blob), 'GitBlob(sha="53bce9fa919b4544e67275089b3ec5b44be20667")',
repr(self.blob),
'GitBlob(sha="53bce9fa919b4544e67275089b3ec5b44be20667")',
)
3 changes: 2 additions & 1 deletion tests/GitTree.py
Expand Up @@ -72,7 +72,8 @@ def testAttributes(self):
)

self.assertEqual(
repr(self.tree), 'GitTree(sha="f492784d8ca837779650d1fb406a1a3587a764ad")',
repr(self.tree),
'GitTree(sha="f492784d8ca837779650d1fb406a1a3587a764ad")',
)
self.assertEqual(
repr(self.tree.tree[0]),
Expand Down
3 changes: 2 additions & 1 deletion tests/GithubApp.py
Expand Up @@ -110,7 +110,8 @@ def testGetAuthenticatedApp(self):
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")
Expand Down
5 changes: 4 additions & 1 deletion tests/GithubIntegration.py
Expand Up @@ -135,7 +135,10 @@ def testCreateJWT(self):
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}
Expand Down
4 changes: 3 additions & 1 deletion tests/NamedUser1430.py
Expand Up @@ -32,5 +32,7 @@ def setUp(self):

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],
)
8 changes: 6 additions & 2 deletions tests/Organization.py
Expand Up @@ -239,10 +239,14 @@ def testGetRepos(self):
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):
Expand Down
12 changes: 9 additions & 3 deletions tests/Project.py
Expand Up @@ -171,22 +171,28 @@ def testCreateColumn(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",
)
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)

def testCreateCardFromIssue(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",
)
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)
Expand Down
3 changes: 2 additions & 1 deletion tests/PullRequest.py
Expand Up @@ -139,7 +139,8 @@ def testAttributes(self):
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),
Expand Down
9 changes: 8 additions & 1 deletion tests/Repository.py
Expand Up @@ -300,7 +300,14 @@ def testCreateGitTreeWithSha(self):

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")

Expand Down
3 changes: 2 additions & 1 deletion tests/UserKey.py
Expand Up @@ -47,7 +47,8 @@ def testAttributes(self):
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):
Expand Down

0 comments on commit 07e29fe

Please sign in to comment.