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:
PIG208 2021-05-28 19:19:40 +08:00 committed by Tim Abbott
parent e27ac0ddbe
commit 9ce7c52a10
78 changed files with 356 additions and 389 deletions

View file

@ -37,7 +37,7 @@ def format_summary_line(
revcount=revcount, s=plural, url=summary_url
)
else:
formatted_commit_count = "{revcount} commit{s}".format(revcount=revcount, s=plural)
formatted_commit_count = f"{revcount} commit{plural}"
return "**{user}** pushed {commits} to **{branch}** (`{tip}:{node}`):\n\n".format(
user=user, commits=formatted_commit_count, branch=branch, tip=tip, node=node[:12]
@ -60,9 +60,9 @@ def format_commit_lines(web_url: str, repo: repo, base: int, tip: int) -> str:
if web_url:
summary_url = rev_base_url + str(rev_ctx)
summary = "* [{summary}]({url})".format(summary=one_liner, url=summary_url)
summary = f"* [{one_liner}]({summary_url})"
else:
summary = "* {summary}".format(summary=one_liner)
summary = f"* {one_liner}"
commit_summaries.append(summary)
@ -95,7 +95,7 @@ def get_config(ui: ui, item: str) -> str:
# config returns configuration value.
return ui.config("zulip", item)
except IndexError:
ui.warn("Zulip: Could not find required item {} in hg config.".format(item))
ui.warn(f"Zulip: Could not find required item {item} in hg config.")
sys.exit(1)
@ -106,10 +106,10 @@ def hook(ui: ui, repo: repo, **kwargs: str) -> None:
hooktype = kwargs["hooktype"]
node = kwargs["node"]
ui.debug("Zulip: received {hooktype} event\n".format(hooktype=hooktype))
ui.debug(f"Zulip: received {hooktype} event\n")
if hooktype != "changegroup":
ui.warn("Zulip: {hooktype} not supported\n".format(hooktype=hooktype))
ui.warn(f"Zulip: {hooktype} not supported\n")
sys.exit(1)
ctx = repo[node]
@ -123,14 +123,14 @@ def hook(ui: ui, repo: repo, **kwargs: str) -> None:
# Only send notifications on branches we are watching.
watched_branches = [b.lower().strip() for b in branch_whitelist.split(",")]
if branch.lower() not in watched_branches:
ui.debug("Zulip: ignoring event for {branch}\n".format(branch=branch))
ui.debug(f"Zulip: ignoring event for {branch}\n")
sys.exit(0)
if branch_blacklist:
# Don't send notifications for branches we've ignored.
ignored_branches = [b.lower().strip() for b in branch_blacklist.split(",")]
if branch.lower() in ignored_branches:
ui.debug("Zulip: ignoring event for {branch}\n".format(branch=branch))
ui.debug(f"Zulip: ignoring event for {branch}\n")
sys.exit(0)
# The first and final commits in the changeset.