aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-08-07 01:21:53 +0100
committerSam James <sam@gentoo.org>2023-08-07 01:23:18 +0100
commitb0a44ba4c6537921bc4802488c3b01699e25307c (patch)
tree8ee2cd258000e75d11f01446531ecce963c5fd45
parentRerun `autopep8` with `--aggressive (diff)
downloadmirrorselect-b0a44ba4c6537921bc4802488c3b01699e25307c.tar.gz
mirrorselect-b0a44ba4c6537921bc4802488c3b01699e25307c.tar.bz2
mirrorselect-b0a44ba4c6537921bc4802488c3b01699e25307c.zip
Rerun `pyupgrade` with `--py39-plus`2.4.0
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--.github/workflows/ci.yml4
-rw-r--r--mirrorselect/extractor.py4
-rw-r--r--mirrorselect/selectors.py19
-rwxr-xr-xsetup.py2
-rw-r--r--tests/test_write_make_conf.py28
5 files changed, 24 insertions, 33 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1f18083..4315aa8 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -9,14 +9,10 @@ jobs:
strategy:
matrix:
python-version:
- - '3.7'
- - '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12-dev'
- - 'pypy-3.7'
- - 'pypy-3.8'
- 'pypy-3.9'
steps:
diff --git a/mirrorselect/extractor.py b/mirrorselect/extractor.py
index 8aa495c..4598b8b 100644
--- a/mirrorselect/extractor.py
+++ b/mirrorselect/extractor.py
@@ -47,9 +47,7 @@ class Extractor:
value = getattr(options, opt)
if value is not None:
filters[opt] = value
- self.output.print_info(
- 'Limiting test to "%s=%s" hosts. \n' % (opt, value)
- )
+ self.output.print_info(f'Limiting test to "{opt}={value}" hosts. \n')
for opt in ["ftp", "http", "https"]:
if getattr(options, opt):
filters["proto"] = opt
diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py
index 7f9fddb..bccb2bf 100644
--- a/mirrorselect/selectors.py
+++ b/mirrorselect/selectors.py
@@ -118,7 +118,7 @@ class Shallow:
self.output.write("Done.\n")
self.output.write(
- "\nnetselect(): returning {} and {}\n".format(top_hosts, top_host_dict), 2
+ f"\nnetselect(): returning {top_hosts} and {top_host_dict}\n", 2
)
if quiet:
@@ -154,7 +154,7 @@ class Shallow:
host_dict = self.netselect(block, len(block), quiet=True)[1]
self.output.write(
- "ran netselect(%s, %s), and got %s\n" % (block, len(block), host_dict),
+ f"ran netselect({block}, {len(block)}), and got {host_dict}\n",
2,
)
@@ -292,7 +292,7 @@ class Deep:
self.output.write("deeptest(): final rethost %s\n" % (rethosts), 2)
self.output.write(
- "deeptest(): final md5 failures %s of %s\n" % (self.dl_failures, num_hosts),
+ f"deeptest(): final md5 failures {self.dl_failures} of {num_hosts}\n",
2,
)
self.urls = rethosts
@@ -336,7 +336,7 @@ class Deep:
signal.alarm(0)
except OSError as e:
self.output.write(
- "deeptime(): dns error for host %s: %s\n" % (url_parts.hostname, e),
+ f"deeptime(): dns error for host {url_parts.hostname}: {e}\n",
2,
)
except TimeoutException:
@@ -351,7 +351,7 @@ class Deep:
return (None, True)
self.output.write(
- "deeptime(): ip's for host %s: %s\n" % (url_parts.hostname, str(ips)), 2
+ f"deeptime(): ip's for host {url_parts.hostname}: {str(ips)}\n", 2
)
delta = 0
f = None
@@ -369,8 +369,7 @@ class Deep:
if f is None:
self.output.write(
- "deeptime(): unable to "
- + "connect to host %s\n" % (url_parts.hostname,),
+ "deeptime(): unable to " + f"connect to host {url_parts.hostname}\n",
2,
)
return (None, True)
@@ -416,7 +415,7 @@ class Deep:
"\ndeeptime(): md5sum error for file: %s\n" % self.test_file
+ " expected: %s\n" % self.test_md5
+ " got.....: %s\n" % md5
- + " host....: %s, %s\n" % (url_parts.hostname, ip)
+ + f" host....: {url_parts.hostname}, {ip}\n"
)
self.dl_failures += 1
return (None, True)
@@ -449,7 +448,7 @@ class Deep:
signal.signal(signal.SIGALRM, signal.SIG_DFL)
self.output.write("deeptime(): download completed.\n", 2)
- self.output.write("deeptime(): %s seconds for host %s\n" % (delta, url), 2)
+ self.output.write(f"deeptime(): {delta} seconds for host {url}\n", 2)
return (delta, False)
def _test_connection(self, test_url, url_parts, ip, ips):
@@ -621,7 +620,7 @@ class Interactive:
dialog.extend(
[
"%s" % url,
- "%s%s: %s" % (marker, args["country"], args["name"]),
+ "{}{}: {}".format(marker, args["country"], args["name"]),
"OFF",
]
)
diff --git a/setup.py b/setup.py
index a8f9313..de41dca 100755
--- a/setup.py
+++ b/setup.py
@@ -54,7 +54,7 @@ class set_version(core.Command):
for line in s:
newline = re.sub(pattern, '"%s"' % ver, line, 1)
if newline != line:
- logging.info("{}: {}".format(f, newline))
+ logging.info(f"{f}: {newline}")
updated_file.append(newline)
with open(f, "w", 1, "utf_8") as s:
s.writelines(updated_file)
diff --git a/tests/test_write_make_conf.py b/tests/test_write_make_conf.py
index 0deee69..4393164 100644
--- a/tests/test_write_make_conf.py
+++ b/tests/test_write_make_conf.py
@@ -26,31 +26,29 @@ class WriteMakeConfTestCase(unittest.TestCase):
with open(config_path) as f:
result = f.read()
# print("!!!result!!!\n", result, "!!!!!!!!!!\n")
- self.assertEqual(
- result, "{}".format(expected_result).format(mirror_string)
- )
+ self.assertEqual(result, f"{expected_result}".format(mirror_string))
finally:
shutil.rmtree(tempdir)
status_output.close()
var = "GENTOO_MIRRORS"
mirrors = (
- ('{}="a"'.format(var)),
- ('{}="a b"'.format(var)),
- ('{}="a b c"'.format(var)),
+ (f'{var}="a"'),
+ (f'{var}="a b"'),
+ (f'{var}="a b c"'),
)
cases = (
- ('{}="foo\nbar"\n'.format(var), "{}\n"),
- ('\n{}="foo\nbar"\n'.format(var), "\n{}\n"),
- ('\n{}="foo bar"\n'.format(var), "\n{}\n"),
- ('\n{}="foo bar"\n\n'.format(var), "\n\n{}\n"),
- ('\n{}="foo \\\nbar"\n'.format(var), "\n{}\n"),
- ('\n\n{}="foo \\\nbar"\n'.format(var), "\n\n{}\n"),
- ('\n\n{}="foo \\\nbar"\na="b"\n'.format(var), '\n\na="b"\n{}\n'),
- ('\n\n{}="foo \\\n bar"\na="b"\n'.format(var), '\n\na="b"\n{}\n'),
+ (f'{var}="foo\nbar"\n', "{}\n"),
+ (f'\n{var}="foo\nbar"\n', "\n{}\n"),
+ (f'\n{var}="foo bar"\n', "\n{}\n"),
+ (f'\n{var}="foo bar"\n\n', "\n\n{}\n"),
+ (f'\n{var}="foo \\\nbar"\n', "\n{}\n"),
+ (f'\n\n{var}="foo \\\nbar"\n', "\n\n{}\n"),
+ (f'\n\n{var}="foo \\\nbar"\na="b"\n', '\n\na="b"\n{}\n'),
+ (f'\n\n{var}="foo \\\n bar"\na="b"\n', '\n\na="b"\n{}\n'),
(
- '\n\n{}="foo \\\n bar\\\n baz"\na="b"\n'.format(var),
+ f'\n\n{var}="foo \\\n bar\\\n baz"\na="b"\n',
'\n\na="b"\n{}\n',
),
("", "{}\n"),