python: Convert more "".format to Python 3.6 f-strings.

Generated by pyupgrade --py36-plus --keep-percent-format.

Now including %d, %i, %u, and multi-line strings.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-06-12 23:57:35 -07:00
committed by Tim Abbott
parent 4aeb02f73d
commit 57a80856a5
14 changed files with 52 additions and 58 deletions

View File

@@ -118,7 +118,7 @@ def set_user_data(username: str, userkey_dicts: List[Dict[str, Any]]) -> str:
server_repo_setup = setup_repo.format(username, "zulip")
python_api_repo_setup = setup_repo.format(username, "python-zulip-api")
cloudconf = """\
cloudconf = f"""\
#!/bin/bash
{setup_zulipdev_ssh_keys}
@@ -130,10 +130,7 @@ su -c '{server_repo_setup}' zulipdev
su -c '{python_api_repo_setup}' zulipdev
su -c 'git config --global core.editor nano' zulipdev
su -c 'git config --global pull.rebase true' zulipdev
""".format(setup_root_ssh_keys=setup_root_ssh_keys,
setup_zulipdev_ssh_keys=setup_zulipdev_ssh_keys,
hostname_setup=hostname_setup,
server_repo_setup=server_repo_setup, python_api_repo_setup=python_api_repo_setup)
"""
print("...returning cloud-config data.")
return cloudconf

View File

@@ -181,9 +181,9 @@ def build_id_dict(templates: List[str]) -> (Dict[str, List[str]]):
try:
list_tags = tokenize(text)
except FormattedException as e:
raise Exception('''
fn: {}
{}'''.format(fn, e))
raise Exception(f'''
fn: {fn}
{e}''')
for tag in list_tags:
info = get_tag_info(tag)

View File

@@ -213,9 +213,9 @@ def validate(fn: Optional[str] = None, text: Optional[str] = None, check_indent:
try:
tokens = tokenize(text)
except FormattedException as e:
raise TemplateParserException('''
fn: {}
{}'''.format(fn, e))
raise TemplateParserException(f'''
fn: {fn}
{e}''')
class State:
def __init__(self, func: Callable[[Token], None]) -> None: