Refactor: More f-string

This commit is contained in:
pagedown
2022-01-28 19:34:13 +08:00
parent e0c4a90aa3
commit dc61adf9d8
14 changed files with 35 additions and 54 deletions

View File

@@ -371,7 +371,7 @@ def expand_opt_references(conf_name: str, text: str) -> str:
ref = m.group(1)
if '<' not in ref and '.' not in ref:
full_ref = conf_name + ref
return ':opt:`{} <{}>`'.format(ref, full_ref)
return f':opt:`{ref} <{full_ref}>`'
return str(m.group())
return re.sub(r':opt:`(.+?)`', expand, text)
@@ -399,7 +399,7 @@ def parse_opt_node(env: Any, sig: str, signode: Any) -> str:
opt_aliases[optname] = firstname
count += 1
if not firstname:
raise ValueError('{} is not a valid opt'.format(sig))
raise ValueError(f'{sig} is not a valid opt')
return firstname
@@ -426,7 +426,7 @@ def process_shortcut_link(env: Any, refnode: Any, has_explicit_title: bool, titl
try:
target, stitle = shortcut_slugs[full_name]
except KeyError:
logger.warning('Unknown shortcut: {}'.format(target), location=refnode)
logger.warning(f'Unknown shortcut: {target}', location=refnode)
else:
if not has_explicit_title:
title = stitle

View File

@@ -108,7 +108,7 @@ features of the graphics protocol:
def serialize_gr_command(**cmd):
payload = cmd.pop('payload', None)
cmd = ','.join('{}={}'.format(k, v) for k, v in cmd.items())
cmd = ','.join(f'{k}={v}' for k, v in cmd.items())
ans = []
w = ans.append
w(b'\033_G'), w(cmd.encode('ascii'))