Skip to content

Commit d858186

Browse files
Use more f-strings instead of .format
1 parent ad5b77b commit d858186

6 files changed

Lines changed: 13 additions & 18 deletions

File tree

zest/releaser/baserelease.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def _insert_changelog_entry(self, message):
295295
if index == 0:
296296
line = f"{prefix} {line}"
297297
else:
298-
line = "{} {}".format(" " * len(prefix), line)
298+
line = f"{' ' * len(prefix)} {line}"
299299
lines.append(line)
300300
lines.append("")
301301
self.data["history_lines"][insert:insert] = lines
@@ -315,8 +315,8 @@ def _check_nothing_changed(self):
315315
# printing text with a u'unicode marker' in front...
316316
pretty_nothing_changed = f'"{nothing_yet}"'
317317
if not utils.ask(
318-
"WARNING: Changelog contains {}. Are you sure you "
319-
"want to release?".format(pretty_nothing_changed),
318+
f"WARNING: Changelog contains {pretty_nothing_changed}. "
319+
"Are you sure you want to release?",
320320
default=False,
321321
):
322322
logger.info(
@@ -343,11 +343,11 @@ def _check_required(self):
343343
if text in history_last_release:
344344
# Found it, all is fine.
345345
return
346-
pretty_required = '"{}"'.format('", "'.join(required))
346+
pretty_required = '", "'.join(required)
347347
if not utils.ask(
348348
"WARNING: Changelog should contain at least one of "
349-
"these required strings: {}. Are you sure you "
350-
"want to release?".format(pretty_required),
349+
f'these required strings: "{pretty_required}". '
350+
"Are you sure you want to release?",
351351
default=False,
352352
):
353353
sys.exit(1)

zest/releaser/bumpversion.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ def prepare(self):
8888
"""Prepare self.data by asking about new dev version"""
8989
if self.data["prerelease"]:
9090
print(
91-
"Checking version bump for {} release and {} prerelease.".format(
92-
self.data["release"], self.data["prerelease"]
93-
)
91+
f"Checking version bump for {self.data['release']} release "
92+
f"and {self.data['prerelease']} prerelease."
9493
)
9594
else:
96-
print("Checking version bump for {} release.".format(self.data["release"]))
95+
print(f"Checking version bump for {self.data['release']} release.")
9796
if not utils.sanity_check(self.vcs):
9897
logger.critical("Sanity check failed.")
9998
sys.exit(1)

zest/releaser/prerelease.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ def prepare(self):
7070
self._grab_history()
7171
if self.data["update_history"]:
7272
# Print changelog for this release.
73-
print(
74-
"Changelog entries for version {}:\n".format(self.data["new_version"])
75-
)
73+
print(f"Changelog entries for version {self.data['new_version']}:\n")
7674
print(self.data.get("history_last_release"))
7775
# Grab and set new version.
7876
self._grab_version()

zest/releaser/tests/test_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
def mock_dispatch(*args):
15-
print("MOCK twine dispatch {}".format(" ".join(*args)))
15+
print(f'MOCK twine dispatch {" ".join(*args)}')
1616
return True
1717

1818

zest/releaser/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ def get_list_item(lines):
10561056
prefix = stripped[0]
10571057
# Restore stripped whitespace.
10581058
white = line.find(prefix)
1059-
unordered_list.append("{}{}".format(" " * white, prefix))
1059+
unordered_list.append(f'{" " * white}{prefix}')
10601060
# Get sane default.
10611061
best = "-"
10621062
count = 0

zest/releaser/vcs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ def __init__(self, reporoot=None):
7575
self.zest_releaser_config = pypi.ZestReleaserConfig()
7676

7777
def __repr__(self):
78-
return "<{} at {} {}>".format(
79-
self.__class__.__name__, self.reporoot, self.relative_path_in_repo
80-
)
78+
return f"<{self.__class__.__name__} at {self.reporoot} {self.relative_path_in_repo}>"
8179

8280
def is_setuptools_helper_package_installed(self):
8381
try:

0 commit comments

Comments
 (0)