Skip to content

Commit a749a0e

Browse files
committed
modernize to f-string
1 parent c6c1822 commit a749a0e

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

diff.py

+11-28
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ def __init__(self):
4141
self.url = None
4242

4343
def __str__(self):
44-
text = "%s %s" % (self.name, self.version)
45-
text += "\r\n%s\r\nWebsite: %s" % (
46-
self.description,
47-
self.url,
48-
)
44+
text = f"{self.name} {self.version}"
45+
text += f"\r\n{self.description}\r\nWebsite: {self.url}"
4946
return text
5047

5148
def from_text(self, text):
@@ -59,26 +56,15 @@ def from_text(self, text):
5956
).groups()
6057

6158
def to_wiki(self):
62-
return " * [%s](%s) %s (%s)\r\n" % (
63-
self.name,
64-
self.url,
65-
self.version,
66-
self.description,
67-
)
59+
return f" * [{self.name}]({self.url}) {self.version} ({self.description})\r\n"
6860

6961
def upgrade_wiki(self, other):
7062
# wheel replace '-' per '_' in package name
7163
assert (
7264
self.name.replace('-', '_').lower()
7365
== other.name.replace('-', '_').lower()
7466
)
75-
return " * [%s](%s) %s → %s (%s)\r\n" % (
76-
self.name,
77-
self.url,
78-
other.version,
79-
self.version,
80-
self.description,
81-
)
67+
return f" * [{self.name}]({self.url}) {other.version}{self.version} ({self.description})\r\n"
8268

8369

8470
class PackageIndex(object):
@@ -181,8 +167,7 @@ def diff_package_dicts(dict1_in, dict2_in):
181167
)
182168
if upgraded_list:
183169
text += (
184-
"Upgraded packages:\r\n\r\n%s\r\n"
185-
% "".join(upgraded_list)
170+
f"Upgraded packages:\r\n\r\n{''.join(upgraded_list}\r\n"
186171
)
187172
# Removed packages
188173
removed = sorted(set1 - set2)
@@ -213,9 +198,9 @@ def find_closer_version(
213198
try:
214199
index = versions.index(version1)
215200
except ValueError:
216-
raise ValueError("Unknown version %s" % version1)
201+
raise ValueError(f"Unknown version {version1}")
217202
if index == 0:
218-
print("No version prior to %s" % version1)
203+
print(f"No version prior to {version1}")
219204
index += 1 # we don't want to fail on this
220205
return versions[index - 1]
221206

@@ -239,12 +224,10 @@ def compare_package_indexes(
239224
flavor1 = flavor1 if flavor1 is not None else flavor
240225
text = '\r\n'.join(
241226
[
242-
"## History of changes for WinPython-%sbit %s"
243-
% (architecture, version2 + flavor),
227+
f"## History of changes for WinPython-{architecture}bit {version2 + flavor}",
244228
"",
245-
"The following changes were made to WinPython-%sbit"
246-
" distribution since version %s."
247-
% (architecture, version1 + flavor1),
229+
f"The following changes were made to WinPython-{architecture}bit"
230+
f" distribution since version {version1 + flavor1}.",
248231
"",
249232
"<details>",
250233
"",
@@ -354,7 +337,7 @@ def test_parse_package_index_wiki(
354337
flavor=flavor,
355338
architecture=architecture,
356339
)
357-
utils.print_box("WinPython %s:" % pi.version)
340+
utils.print_box(f"WinPython {pi.version}:")
358341
utils.print_box("Tools:")
359342
for package in pi.other_packages.values():
360343
print(package)

0 commit comments

Comments
 (0)