pyupgrade: Reformat with --py36-plus.
This includes mainly fixes of string literals using f-strings or .format(...), as well as unpacking of list comprehensions.
This commit is contained in:
parent
e27ac0ddbe
commit
9ce7c52a10
78 changed files with 356 additions and 389 deletions
|
@ -41,14 +41,14 @@ def git_repository_name() -> str:
|
|||
|
||||
|
||||
def git_commit_range(oldrev: str, newrev: str) -> str:
|
||||
log_cmd = ["git", "log", "--reverse", "--pretty=%aE %H %s", "%s..%s" % (oldrev, newrev)]
|
||||
log_cmd = ["git", "log", "--reverse", "--pretty=%aE %H %s", f"{oldrev}..{newrev}"]
|
||||
commits = ""
|
||||
for ln in subprocess.check_output(log_cmd, universal_newlines=True).splitlines():
|
||||
author_email, commit_id, subject = ln.split(None, 2)
|
||||
if hasattr(config, "format_commit_message"):
|
||||
commits += config.format_commit_message(author_email, subject, commit_id)
|
||||
else:
|
||||
commits += "!avatar(%s) %s\n" % (author_email, subject)
|
||||
commits += f"!avatar({author_email}) {subject}\n"
|
||||
return commits
|
||||
|
||||
|
||||
|
@ -75,19 +75,19 @@ def send_bot_message(oldrev: str, newrev: str, refname: str) -> None:
|
|||
removed = git_commit_range(newrev, oldrev)
|
||||
|
||||
if oldrev == "0000000000000000000000000000000000000000":
|
||||
message = "`%s` was pushed to new branch `%s`" % (new_head, branch)
|
||||
message = f"`{new_head}` was pushed to new branch `{branch}`"
|
||||
elif newrev == "0000000000000000000000000000000000000000":
|
||||
message = "branch `%s` was removed (was `%s`)" % (branch, old_head)
|
||||
message = f"branch `{branch}` was removed (was `{old_head}`)"
|
||||
elif removed:
|
||||
message = "`%s` was pushed to `%s`, **REMOVING**:\n\n%s" % (new_head, branch, removed)
|
||||
message = f"`{new_head}` was pushed to `{branch}`, **REMOVING**:\n\n{removed}"
|
||||
if added:
|
||||
message += "\n**and adding**:\n\n" + added
|
||||
message += "\n**A HISTORY REWRITE HAS OCCURRED!**"
|
||||
message += "\n@everyone: Please check your local branches to deal with this."
|
||||
elif added:
|
||||
message = "`%s` was deployed to `%s` with:\n\n%s" % (new_head, branch, added)
|
||||
message = f"`{new_head}` was deployed to `{branch}` with:\n\n{added}"
|
||||
else:
|
||||
message = "`%s` was pushed to `%s`... but nothing changed?" % (new_head, branch)
|
||||
message = f"`{new_head}` was pushed to `{branch}`... but nothing changed?"
|
||||
|
||||
message_data = {
|
||||
"type": "stream",
|
||||
|
|
|
@ -25,7 +25,7 @@ ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
|
|||
# And similarly for branch "test-post-receive" (for use when testing).
|
||||
def commit_notice_destination(repo: str, branch: str, commit: str) -> Optional[Dict[str, str]]:
|
||||
if branch in ["master", "test-post-receive"]:
|
||||
return dict(stream=STREAM_NAME, subject="%s" % (branch,))
|
||||
return dict(stream=STREAM_NAME, subject=f"{branch}")
|
||||
|
||||
# Return None for cases where you don't want a notice sent
|
||||
return None
|
||||
|
@ -37,7 +37,7 @@ def commit_notice_destination(repo: str, branch: str, commit: str) -> Optional[D
|
|||
#
|
||||
# return '!avatar(%s) [%s](https://example.com/commits/%s)\n' % (author, subject, commit_id)
|
||||
def format_commit_message(author: str, subject: str, commit_id: str) -> str:
|
||||
return "!avatar(%s) %s\n" % (author, subject)
|
||||
return f"!avatar({author}) {subject}\n"
|
||||
|
||||
|
||||
## If properly installed, the Zulip API should be in your import
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue