Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch all string addition to using f-strings #1774

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 20 additions & 22 deletions github/AuthenticatedUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def add_to_following(self, following):
"""
assert isinstance(following, github.NamedUser.NamedUser), following
headers, data = self._requester.requestJsonAndCheck(
"PUT", "/user/following/" + following._identity
"PUT", f"/user/following/{following._identity}"
)

def add_to_starred(self, starred):
Expand All @@ -397,7 +397,7 @@ def add_to_starred(self, starred):
"""
assert isinstance(starred, github.Repository.Repository), starred
headers, data = self._requester.requestJsonAndCheck(
"PUT", "/user/starred/" + starred._identity
"PUT", f"/user/starred/{starred._identity}"
)

def add_to_subscriptions(self, subscription):
Expand All @@ -408,7 +408,7 @@ def add_to_subscriptions(self, subscription):
"""
assert isinstance(subscription, github.Repository.Repository), subscription
headers, data = self._requester.requestJsonAndCheck(
"PUT", "/user/subscriptions/" + subscription._identity
"PUT", f"/user/subscriptions/{subscription._identity}"
)

def add_to_watched(self, watched):
Expand All @@ -420,7 +420,7 @@ def add_to_watched(self, watched):
assert isinstance(watched, github.Repository.Repository), watched
headers, data = self._requester.requestJsonAndCheck(
"PUT",
"/repos/" + watched._identity + "/subscription",
f"/repos/{watched._identity}/subscription",
input={"subscribed": True},
)

Expand Down Expand Up @@ -494,7 +494,7 @@ def create_fork(self, repo):
"""
assert isinstance(repo, github.Repository.Repository), repo
headers, data = self._requester.requestJsonAndCheck(
"POST", "/repos/" + repo.owner.login + "/" + repo.name + "/forks"
"POST", f"/repos/{repo.owner.login}/{repo.name}/forks"
)
return github.Repository.Repository(
self._requester, headers, data, completed=True
Expand Down Expand Up @@ -745,7 +745,7 @@ def get_authorization(self, id):
"""
assert isinstance(id, int), id
headers, data = self._requester.requestJsonAndCheck(
"GET", "/authorizations/" + str(id)
"GET", f"/authorizations/{id}"
)
return github.Authorization.Authorization(
self._requester, headers, data, completed=True
Expand Down Expand Up @@ -916,9 +916,7 @@ def get_key(self, id):
:rtype: :class:`github.UserKey.UserKey`
"""
assert isinstance(id, int), id
headers, data = self._requester.requestJsonAndCheck(
"GET", "/user/keys/" + str(id)
)
headers, data = self._requester.requestJsonAndCheck("GET", f"/user/keys/{id}")
return github.UserKey.UserKey(self._requester, headers, data, completed=True)

def get_keys(self):
Expand All @@ -938,7 +936,7 @@ def get_notification(self, id):

assert isinstance(id, str), id
headers, data = self._requester.requestJsonAndCheck(
"GET", "/notifications/threads/" + id
"GET", f"/notifications/threads/{id}"
)
return github.Notification.Notification(
self._requester, headers, data, completed=True
Expand Down Expand Up @@ -995,7 +993,7 @@ def get_organization_events(self, org):
return github.PaginatedList.PaginatedList(
github.Event.Event,
self._requester,
"/users/" + self.login + "/events/orgs/" + org.login,
f"/users/{self.login}/events/orgs/{org.login}",
None,
)

Expand All @@ -1016,7 +1014,7 @@ def get_repo(self, name):
"""
assert isinstance(name, str), name
headers, data = self._requester.requestJsonAndCheck(
"GET", "/repos/" + self.login + "/" + name
"GET", f"/repos/{self.login}/{name}"
)
return github.Repository.Repository(
self._requester, headers, data, completed=True
Expand Down Expand Up @@ -1132,7 +1130,7 @@ def has_in_following(self, following):
"""
assert isinstance(following, github.NamedUser.NamedUser), following
status, headers, data = self._requester.requestJson(
"GET", "/user/following/" + following._identity
"GET", f"/user/following/{following._identity}"
)
return status == 204

Expand All @@ -1144,7 +1142,7 @@ def has_in_starred(self, starred):
"""
assert isinstance(starred, github.Repository.Repository), starred
status, headers, data = self._requester.requestJson(
"GET", "/user/starred/" + starred._identity
"GET", f"/user/starred/{starred._identity}"
)
return status == 204

Expand All @@ -1156,7 +1154,7 @@ def has_in_subscriptions(self, subscription):
"""
assert isinstance(subscription, github.Repository.Repository), subscription
status, headers, data = self._requester.requestJson(
"GET", "/user/subscriptions/" + subscription._identity
"GET", f"/user/subscriptions/{subscription._identity}"
)
return status == 204

Expand All @@ -1168,7 +1166,7 @@ def has_in_watched(self, watched):
"""
assert isinstance(watched, github.Repository.Repository), watched
status, headers, data = self._requester.requestJson(
"GET", "/repos/" + watched._identity + "/subscription"
"GET", f"/repos/{watched._identity}/subscription"
)
return status == 200

Expand Down Expand Up @@ -1204,7 +1202,7 @@ def remove_from_following(self, following):
"""
assert isinstance(following, github.NamedUser.NamedUser), following
headers, data = self._requester.requestJsonAndCheck(
"DELETE", "/user/following/" + following._identity
"DELETE", f"/user/following/{following._identity}"
)

def remove_from_starred(self, starred):
Expand All @@ -1215,7 +1213,7 @@ def remove_from_starred(self, starred):
"""
assert isinstance(starred, github.Repository.Repository), starred
headers, data = self._requester.requestJsonAndCheck(
"DELETE", "/user/starred/" + starred._identity
"DELETE", f"/user/starred/{starred._identity}"
)

def remove_from_subscriptions(self, subscription):
Expand All @@ -1226,7 +1224,7 @@ def remove_from_subscriptions(self, subscription):
"""
assert isinstance(subscription, github.Repository.Repository), subscription
headers, data = self._requester.requestJsonAndCheck(
"DELETE", "/user/subscriptions/" + subscription._identity
"DELETE", f"/user/subscriptions/{subscription._identity}"
)

def remove_from_watched(self, watched):
Expand All @@ -1237,7 +1235,7 @@ def remove_from_watched(self, watched):
"""
assert isinstance(watched, github.Repository.Repository), watched
headers, data = self._requester.requestJsonAndCheck(
"DELETE", "/repos/" + watched._identity + "/subscription"
"DELETE", f"/repos/{watched._identity}/subscription"
)

def accept_invitation(self, invitation):
Expand All @@ -1254,7 +1252,7 @@ def accept_invitation(self, invitation):
invitation = invitation.id

headers, data = self._requester.requestJsonAndCheck(
"PATCH", "/user/repository_invitations/" + str(invitation), input={}
"PATCH", f"/user/repository_invitations/{invitation}", input={}
)

def get_invitations(self):
Expand Down Expand Up @@ -1325,7 +1323,7 @@ def get_organization_membership(self, org):
"""
assert isinstance(org, str)
headers, data = self._requester.requestJsonAndCheck(
"GET", "/user/memberships/orgs/" + org
"GET", f"/user/memberships/orgs/{org}"
)
return github.Membership.Membership(
self._requester, headers, data, completed=True
Expand Down
44 changes: 23 additions & 21 deletions github/Branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def get_required_status_checks(self):
:rtype: :class:`github.RequiredStatusChecks.RequiredStatusChecks`
"""
headers, data = self._requester.requestJsonAndCheck(
"GET", self.protection_url + "/required_status_checks"
"GET", f"{self.protection_url}/required_status_checks"
)
return github.RequiredStatusChecks.RequiredStatusChecks(
self._requester, headers, data, completed=True
Expand All @@ -284,7 +284,7 @@ def edit_required_status_checks(
post_parameters["contexts"] = contexts
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.protection_url + "/required_status_checks",
f"{self.protection_url}/required_status_checks",
input=post_parameters,
)

Expand All @@ -293,7 +293,8 @@ def remove_required_status_checks(self):
:calls: `DELETE /repos/:owner/:repo/branches/:branch/protection/required_status_checks <https://developer.github.com/v3/repos/branches>`_
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE", self.protection_url + "/required_status_checks"
"DELETE",
f"{self.protection_url}/required_status_checks",
)

def get_required_pull_request_reviews(self):
Expand All @@ -303,7 +304,7 @@ def get_required_pull_request_reviews(self):
"""
headers, data = self._requester.requestJsonAndCheck(
"GET",
self.protection_url + "/required_pull_request_reviews",
f"{self.protection_url}/required_pull_request_reviews",
headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews},
)
return github.RequiredPullRequestReviews.RequiredPullRequestReviews(
Expand Down Expand Up @@ -360,7 +361,7 @@ def edit_required_pull_request_reviews(
] = required_approving_review_count
headers, data = self._requester.requestJsonAndCheck(
"PATCH",
self.protection_url + "/required_pull_request_reviews",
f"{self.protection_url}/required_pull_request_reviews",
headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews},
input=post_parameters,
)
Expand All @@ -370,7 +371,8 @@ def remove_required_pull_request_reviews(self):
:calls: `DELETE /repos/:owner/:repo/branches/:branch/protection/required_pull_request_reviews <https://developer.github.com/v3/repos/branches>`_
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE", self.protection_url + "/required_pull_request_reviews"
"DELETE",
f"{self.protection_url}/required_pull_request_reviews",
)

def get_admin_enforcement(self):
Expand All @@ -379,7 +381,7 @@ def get_admin_enforcement(self):
:rtype: bool
"""
headers, data = self._requester.requestJsonAndCheck(
"GET", self.protection_url + "/enforce_admins"
"GET", f"{self.protection_url}/enforce_admins"
)
return data["enabled"]

Expand All @@ -388,15 +390,15 @@ def set_admin_enforcement(self):
:calls: `POST /repos/:owner/:repo/branches/:branch/protection/enforce_admins <https://developer.github.com/v3/repos/branches>`_
"""
headers, data = self._requester.requestJsonAndCheck(
"POST", self.protection_url + "/enforce_admins"
"POST", f"{self.protection_url}/enforce_admins"
)

def remove_admin_enforcement(self):
"""
:calls: `DELETE /repos/:owner/:repo/branches/:branch/protection/enforce_admins <https://developer.github.com/v3/repos/branches>`_
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE", self.protection_url + "/enforce_admins"
"DELETE", f"{self.protection_url}/enforce_admins"
)

def get_user_push_restrictions(self):
Expand All @@ -407,7 +409,7 @@ def get_user_push_restrictions(self):
return github.PaginatedList.PaginatedList(
github.NamedUser.NamedUser,
self._requester,
self.protection_url + "/restrictions/users",
f"{self.protection_url}/restrictions/users",
None,
)

Expand All @@ -419,7 +421,7 @@ def get_team_push_restrictions(self):
return github.PaginatedList.PaginatedList(
github.Team.Team,
self._requester,
self.protection_url + "/restrictions/teams",
f"{self.protection_url}/restrictions/teams",
None,
)

Expand All @@ -431,7 +433,7 @@ def add_user_push_restrictions(self, *users):
assert all(isinstance(element, str) for element in users), users

headers, data = self._requester.requestJsonAndCheck(
"POST", self.protection_url + "/restrictions/users", input=users
"POST", f"{self.protection_url}/restrictions/users", input=users
)

def replace_user_push_restrictions(self, *users):
Expand All @@ -442,7 +444,7 @@ def replace_user_push_restrictions(self, *users):
assert all(isinstance(element, str) for element in users), users

headers, data = self._requester.requestJsonAndCheck(
"PUT", self.protection_url + "/restrictions/users", input=users
"PUT", f"{self.protection_url}/restrictions/users", input=users
)

def remove_user_push_restrictions(self, *users):
Expand All @@ -453,7 +455,7 @@ def remove_user_push_restrictions(self, *users):
assert all(isinstance(element, str) for element in users), users

headers, data = self._requester.requestJsonAndCheck(
"DELETE", self.protection_url + "/restrictions/users", input=users
"DELETE", f"{self.protection_url}/restrictions/users", input=users
)

def add_team_push_restrictions(self, *teams):
Expand All @@ -464,7 +466,7 @@ def add_team_push_restrictions(self, *teams):
assert all(isinstance(element, str) for element in teams), teams

headers, data = self._requester.requestJsonAndCheck(
"POST", self.protection_url + "/restrictions/teams", input=teams
"POST", f"{self.protection_url}/restrictions/teams", input=teams
)

def replace_team_push_restrictions(self, *teams):
Expand All @@ -475,7 +477,7 @@ def replace_team_push_restrictions(self, *teams):
assert all(isinstance(element, str) for element in teams), teams

headers, data = self._requester.requestJsonAndCheck(
"PUT", self.protection_url + "/restrictions/teams", input=teams
"PUT", f"{self.protection_url}/restrictions/teams", input=teams
)

def remove_team_push_restrictions(self, *teams):
Expand All @@ -486,15 +488,15 @@ def remove_team_push_restrictions(self, *teams):
assert all(isinstance(element, str) for element in teams), teams

headers, data = self._requester.requestJsonAndCheck(
"DELETE", self.protection_url + "/restrictions/teams", input=teams
"DELETE", f"{self.protection_url}/restrictions/teams", input=teams
)

def remove_push_restrictions(self):
"""
:calls: `DELETE /repos/:owner/:repo/branches/:branch/protection/restrictions <https://developer.github.com/v3/repos/branches>`_
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE", self.protection_url + "/restrictions"
"DELETE", f"{self.protection_url}/restrictions"
)

def get_required_signatures(self):
Expand All @@ -503,7 +505,7 @@ def get_required_signatures(self):
"""
headers, data = self._requester.requestJsonAndCheck(
"GET",
self.protection_url + "/required_signatures",
f"{self.protection_url}/required_signatures",
headers={"Accept": Consts.signaturesProtectedBranchesPreview},
)
return data["enabled"]
Expand All @@ -514,7 +516,7 @@ def add_required_signatures(self):
"""
headers, data = self._requester.requestJsonAndCheck(
"POST",
self.protection_url + "/required_signatures",
f"{self.protection_url}/required_signatures",
headers={"Accept": Consts.signaturesProtectedBranchesPreview},
)

Expand All @@ -524,6 +526,6 @@ def remove_required_signatures(self):
"""
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
self.protection_url + "/required_signatures",
f"{self.protection_url}/required_signatures",
headers={"Accept": Consts.signaturesProtectedBranchesPreview},
)
2 changes: 1 addition & 1 deletion github/CheckRun.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_annotations(self):
return github.PaginatedList.PaginatedList(
github.CheckRunAnnotation.CheckRunAnnotation,
self._requester,
self.url + "/annotations",
f"{self.url}/annotations",
None,
headers={"Accept": "application/vnd.github.v3+json"},
)
Expand Down
4 changes: 2 additions & 2 deletions github/CheckSuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def rerequest(self):
"""
request_headers = {"Accept": "application/vnd.github.v3+json"}
status, _, _ = self._requester.requestJson(
"POST", self.url + "/rerequest", headers=request_headers
"POST", f"{self.url}/rerequest", headers=request_headers
)
return status == 201

Expand Down Expand Up @@ -198,7 +198,7 @@ def get_check_runs(
return github.PaginatedList.PaginatedList(
github.CheckRun.CheckRun,
self._requester,
self.url + "/check-runs",
f"{self.url}/check-runs",
url_parameters,
headers={"Accept": "application/vnd.github.v3+json"},
list_item="check_runs",
Expand Down