Skip to content

Commit 8291ae3

Browse files
rodolfomp123blurb-it[bot]gpshead
authored
GH-103805: Lib test f541 linting issue fix (#103812)
This PR makes some minor linting adjustments to the Lib/test module caught by [ruff](https://github.com/charliermarsh/ruff). The adjustments are all related to the `F541 f-string without any placeholders` issue. Issue: #103805 <!-- gh-issue-number: gh-103805 --> * Issue: gh-103805 <!-- /gh-issue-number --> --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <[email protected]>
1 parent df3173d commit 8291ae3

14 files changed

+90
-90
lines changed

Lib/test/test__xxinterpchannels.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,19 +1469,19 @@ def _assert_closed_in_interp(self, fix, interp=None):
14691469
with self.assertRaises(channels.ChannelClosedError):
14701470
channels.close(fix.cid, force=True)
14711471
else:
1472-
run_interp(interp.id, f"""
1472+
run_interp(interp.id, """
14731473
with helpers.expect_channel_closed():
14741474
channels.recv(cid)
14751475
""")
1476-
run_interp(interp.id, f"""
1476+
run_interp(interp.id, """
14771477
with helpers.expect_channel_closed():
14781478
channels.send(cid, b'spam')
14791479
""")
1480-
run_interp(interp.id, f"""
1480+
run_interp(interp.id, """
14811481
with helpers.expect_channel_closed():
14821482
channels.close(cid)
14831483
""")
1484-
run_interp(interp.id, f"""
1484+
run_interp(interp.id, """
14851485
with helpers.expect_channel_closed():
14861486
channels.close(cid, force=True)
14871487
""")

Lib/test/test__xxsubinterpreters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ def test_shared_overwrites(self):
798798
"""))
799799

800800
shared = {'spam': b'ham'}
801-
script = dedent(f"""
801+
script = dedent("""
802802
ns2 = dict(vars())
803803
del ns2['__builtins__']
804804
""")
@@ -902,7 +902,7 @@ def test_execution_namespace_is_main(self):
902902
# XXX Fix this test!
903903
@unittest.skip('blocking forever')
904904
def test_still_running_at_exit(self):
905-
script = dedent(f"""
905+
script = dedent("""
906906
from textwrap import dedent
907907
import threading
908908
import _xxsubinterpreters as _interpreters

Lib/test/test_capi/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ def callback():
14211421
@threading_helper.requires_working_threading()
14221422
def test_gilstate_ensure_no_deadlock(self):
14231423
# See https://github.com/python/cpython/issues/96071
1424-
code = textwrap.dedent(f"""
1424+
code = textwrap.dedent("""
14251425
import _testcapi
14261426
14271427
def callback():

Lib/test/test_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def foo():
356356
foo.__code__ = foo.__code__.replace(
357357
co_code=b'\xe5' + foo.__code__.co_code[1:])
358358

359-
msg = f"unknown opcode 229"
359+
msg = "unknown opcode 229"
360360
with self.assertRaisesRegex(SystemError, msg):
361361
foo()
362362

Lib/test/test_collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ def test_Set_from_iterable(self):
16261626
class SetUsingInstanceFromIterable(MutableSet):
16271627
def __init__(self, values, created_by):
16281628
if not created_by:
1629-
raise ValueError(f'created_by must be specified')
1629+
raise ValueError('created_by must be specified')
16301630
self.created_by = created_by
16311631
self._values = set(values)
16321632

Lib/test/test_coroutines.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,15 +2365,15 @@ def check(depth, msg):
23652365
f"coroutine '{corofn.__qualname__}' was never awaited\n",
23662366
"Coroutine created at (most recent call last)\n",
23672367
f' File "{a1_filename}", line {a1_lineno}, in a1\n',
2368-
f' return corofn() # comment in a1',
2368+
" return corofn() # comment in a1",
23692369
]))
23702370
check(2, "".join([
23712371
f"coroutine '{corofn.__qualname__}' was never awaited\n",
23722372
"Coroutine created at (most recent call last)\n",
23732373
f' File "{a2_filename}", line {a2_lineno}, in a2\n',
2374-
f' return a1() # comment in a2\n',
2374+
" return a1() # comment in a2\n",
23752375
f' File "{a1_filename}", line {a1_lineno}, in a1\n',
2376-
f' return corofn() # comment in a1',
2376+
" return corofn() # comment in a1",
23772377
]))
23782378

23792379
finally:

Lib/test/test_dataclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,8 @@ class Point:
757757
class Subclass(typ): pass
758758

759759
with self.assertRaisesRegex(ValueError,
760-
f"mutable default .*Subclass'>"
761-
' for field z is not allowed'
760+
"mutable default .*Subclass'>"
761+
" for field z is not allowed"
762762
):
763763
@dataclass
764764
class Point:

Lib/test/test_embed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def run_embedded_interpreter(self, *args, env=None,
110110
print(f"--- {cmd} failed ---")
111111
print(f"stdout:\n{out}")
112112
print(f"stderr:\n{err}")
113-
print(f"------")
113+
print("------")
114114

115115
self.assertEqual(p.returncode, returncode,
116116
"bad returncode %d, stderr is %r" %

Lib/test/test_import/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ def from_module(cls, mod):
18871887
self.init_count = mod.initialized_count()
18881888
return self
18891889

1890-
SCRIPT_BODY = ModuleSnapshot.SCRIPT_BODY + textwrap.dedent(f'''
1890+
SCRIPT_BODY = ModuleSnapshot.SCRIPT_BODY + textwrap.dedent('''
18911891
snapshot['module'].update(dict(
18921892
int_const=mod.int_const,
18931893
str_const=mod.str_const,

Lib/test/test_launcher.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,17 @@ def test_filter_to_company_with_default(self):
394394

395395
def test_filter_to_tag(self):
396396
company = "PythonTestSuite"
397-
data = self.run_py([f"-V:3.100"])
397+
data = self.run_py(["-V:3.100"])
398398
self.assertEqual("X.Y.exe", data["LaunchCommand"])
399399
self.assertEqual(company, data["env.company"])
400400
self.assertEqual("3.100", data["env.tag"])
401401

402-
data = self.run_py([f"-V:3.100-32"])
402+
data = self.run_py(["-V:3.100-32"])
403403
self.assertEqual("X.Y-32.exe", data["LaunchCommand"])
404404
self.assertEqual(company, data["env.company"])
405405
self.assertEqual("3.100-32", data["env.tag"])
406406

407-
data = self.run_py([f"-V:3.100-arm64"])
407+
data = self.run_py(["-V:3.100-arm64"])
408408
self.assertEqual("X.Y-arm64.exe -X fake_arg_for_test", data["LaunchCommand"])
409409
self.assertEqual(company, data["env.company"])
410410
self.assertEqual("3.100-arm64", data["env.tag"])
@@ -421,7 +421,7 @@ def test_filter_to_company_and_tag(self):
421421
def test_filter_with_single_install(self):
422422
company = "PythonTestSuite1"
423423
data = self.run_py(
424-
[f"-V:Nonexistent"],
424+
["-V:Nonexistent"],
425425
env={"PYLAUNCHER_LIMIT_TO_COMPANY": company},
426426
expect_returncode=103,
427427
)
@@ -500,7 +500,7 @@ def test_py_default_short_argv0(self):
500500
data = self.run_py(["--version"], argv=f'{argv0} --version')
501501
self.assertEqual("PythonTestSuite", data["SearchInfo.company"])
502502
self.assertEqual("3.100", data["SearchInfo.tag"])
503-
self.assertEqual(f'X.Y.exe --version', data["stdout"].strip())
503+
self.assertEqual("X.Y.exe --version", data["stdout"].strip())
504504

505505
def test_py_default_in_list(self):
506506
data = self.run_py(["-0"], env=TEST_PY_ENV)
@@ -662,38 +662,38 @@ def test_install(self):
662662
self.assertIn("9PJPW5LDXLZ5", cmd)
663663

664664
def test_literal_shebang_absolute(self):
665-
with self.script(f"#! C:/some_random_app -witharg") as script:
665+
with self.script("#! C:/some_random_app -witharg") as script:
666666
data = self.run_py([script])
667667
self.assertEqual(
668668
f"C:\\some_random_app -witharg {script}",
669669
data["stdout"].strip(),
670670
)
671671

672672
def test_literal_shebang_relative(self):
673-
with self.script(f"#! ..\\some_random_app -witharg") as script:
673+
with self.script("#! ..\\some_random_app -witharg") as script:
674674
data = self.run_py([script])
675675
self.assertEqual(
676676
f"{script.parent.parent}\\some_random_app -witharg {script}",
677677
data["stdout"].strip(),
678678
)
679679

680680
def test_literal_shebang_quoted(self):
681-
with self.script(f'#! "some random app" -witharg') as script:
681+
with self.script('#! "some random app" -witharg') as script:
682682
data = self.run_py([script])
683683
self.assertEqual(
684684
f'"{script.parent}\\some random app" -witharg {script}',
685685
data["stdout"].strip(),
686686
)
687687

688-
with self.script(f'#! some" random "app -witharg') as script:
688+
with self.script('#! some" random "app -witharg') as script:
689689
data = self.run_py([script])
690690
self.assertEqual(
691691
f'"{script.parent}\\some random app" -witharg {script}',
692692
data["stdout"].strip(),
693693
)
694694

695695
def test_literal_shebang_quoted_escape(self):
696-
with self.script(f'#! some\\" random "app -witharg') as script:
696+
with self.script('#! some\\" random "app -witharg') as script:
697697
data = self.run_py([script])
698698
self.assertEqual(
699699
f'"{script.parent}\\some\\ random app" -witharg {script}',

0 commit comments

Comments
 (0)