]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-103805: Lib test f541 linting issue fix (#103812)
authorRodolfo M. Pereira <rodolfomp123@gmail.com>
Mon, 24 Apr 2023 23:24:49 +0000 (17:24 -0600)
committerGitHub <noreply@github.com>
Mon, 24 Apr 2023 23:24:49 +0000 (23:24 +0000)
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: https://github.com/python/cpython/issues/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 <greg@krypto.org>
14 files changed:
Lib/test/test__xxinterpchannels.py
Lib/test/test__xxsubinterpreters.py
Lib/test/test_capi/test_misc.py
Lib/test/test_code.py
Lib/test/test_collections.py
Lib/test/test_coroutines.py
Lib/test/test_dataclasses.py
Lib/test/test_embed.py
Lib/test/test_import/__init__.py
Lib/test/test_launcher.py
Lib/test/test_peepholer.py
Lib/test/test_sqlite3/test_regression.py
Lib/test/test_sqlite3/test_userfunctions.py
Lib/test/test_traceback.py

index b65281106f667ce5368545c748e19cf1dd3f1313..750cd99b85e7a67a4ef288b7ff923b613d07ab77 100644 (file)
@@ -1469,19 +1469,19 @@ class ExhaustiveChannelTests(TestBase):
             with self.assertRaises(channels.ChannelClosedError):
                 channels.close(fix.cid, force=True)
         else:
-            run_interp(interp.id, f"""
+            run_interp(interp.id, """
                 with helpers.expect_channel_closed():
                     channels.recv(cid)
                 """)
-            run_interp(interp.id, f"""
+            run_interp(interp.id, """
                 with helpers.expect_channel_closed():
                     channels.send(cid, b'spam')
                 """)
-            run_interp(interp.id, f"""
+            run_interp(interp.id, """
                 with helpers.expect_channel_closed():
                     channels.close(cid)
                 """)
-            run_interp(interp.id, f"""
+            run_interp(interp.id, """
                 with helpers.expect_channel_closed():
                     channels.close(cid, force=True)
                 """)
index 965967e3f2734b4f0115d781937246b3eade5b88..1ee18774d1720960c6da44b7d6c017961d418c38 100644 (file)
@@ -798,7 +798,7 @@ class RunStringTests(TestBase):
             """))
 
         shared = {'spam': b'ham'}
-        script = dedent(f"""
+        script = dedent("""
             ns2 = dict(vars())
             del ns2['__builtins__']
         """)
@@ -902,7 +902,7 @@ class RunStringTests(TestBase):
     # XXX Fix this test!
     @unittest.skip('blocking forever')
     def test_still_running_at_exit(self):
-        script = dedent(f"""
+        script = dedent("""
         from textwrap import dedent
         import threading
         import _xxsubinterpreters as _interpreters
index eab693001961a8eb67f67067ff2a3e325da8c89f..9470cf12a7d1c4cf87005a7d2dfaaf5174800f97 100644 (file)
@@ -1421,7 +1421,7 @@ class TestThreadState(unittest.TestCase):
     @threading_helper.requires_working_threading()
     def test_gilstate_ensure_no_deadlock(self):
         # See https://github.com/python/cpython/issues/96071
-        code = textwrap.dedent(f"""
+        code = textwrap.dedent("""
             import _testcapi
 
             def callback():
index ecb3525a92846832010b29a592233b10070018ea..ca06a39f5df142f44caa63321e157d9a94318f71 100644 (file)
@@ -356,7 +356,7 @@ class CodeTest(unittest.TestCase):
         foo.__code__ = foo.__code__.replace(
             co_code=b'\xe5' + foo.__code__.co_code[1:])
 
-        msg = f"unknown opcode 229"
+        msg = "unknown opcode 229"
         with self.assertRaisesRegex(SystemError, msg):
             foo()
 
index bfe18c7fc503305297f47fadf6897d65a778a2f5..fb568a48396498b8164a25338a2264c64ae31d05 100644 (file)
@@ -1626,7 +1626,7 @@ class TestCollectionABCs(ABCTestCase):
         class SetUsingInstanceFromIterable(MutableSet):
             def __init__(self, values, created_by):
                 if not created_by:
-                    raise ValueError(f'created_by must be specified')
+                    raise ValueError('created_by must be specified')
                 self.created_by = created_by
                 self._values = set(values)
 
index 6ab19efcc588b8780acd676d2feebbcb1dcc068c..47145782c0f04f70f6cef7f78288ab446b631331 100644 (file)
@@ -2365,15 +2365,15 @@ class OriginTrackingTest(unittest.TestCase):
                 f"coroutine '{corofn.__qualname__}' was never awaited\n",
                 "Coroutine created at (most recent call last)\n",
                 f'  File "{a1_filename}", line {a1_lineno}, in a1\n',
-                f'    return corofn()  # comment in a1',
+                "    return corofn()  # comment in a1",
             ]))
             check(2, "".join([
                 f"coroutine '{corofn.__qualname__}' was never awaited\n",
                 "Coroutine created at (most recent call last)\n",
                 f'  File "{a2_filename}", line {a2_lineno}, in a2\n',
-                f'    return a1()  # comment in a2\n',
+                "    return a1()  # comment in a2\n",
                 f'  File "{a1_filename}", line {a1_lineno}, in a1\n',
-                f'    return corofn()  # comment in a1',
+                "    return corofn()  # comment in a1",
             ]))
 
         finally:
index ae8bfcc149e86216082ef6e21b727b22035d0a28..7dd81a8855f1be0fe77b6b81b999ed575fc7a95a 100644 (file)
@@ -757,8 +757,8 @@ class TestCase(unittest.TestCase):
                 class Subclass(typ): pass
 
                 with self.assertRaisesRegex(ValueError,
-                                            f"mutable default .*Subclass'>"
-                                            ' for field z is not allowed'
+                                            "mutable default .*Subclass'>"
+                                            " for field z is not allowed"
                                             ):
                     @dataclass
                     class Point:
index f702ffb99905a54a608f8ff544f64abc60d3d29d..c9691bbf304915785a455dba9175dc5f8ebd27c5 100644 (file)
@@ -110,7 +110,7 @@ class EmbeddingTestsMixin:
             print(f"--- {cmd} failed ---")
             print(f"stdout:\n{out}")
             print(f"stderr:\n{err}")
-            print(f"------")
+            print("------")
 
         self.assertEqual(p.returncode, returncode,
                          "bad returncode %d, stderr is %r" %
index f206e52faf8c5ca9c09356c2c7af9b212f1a2cef..41dfdaabe24664fe060ea4d7143396b47ee1d206 100644 (file)
@@ -1887,7 +1887,7 @@ class TestSinglePhaseSnapshot(ModuleSnapshot):
             self.init_count = mod.initialized_count()
         return self
 
-    SCRIPT_BODY = ModuleSnapshot.SCRIPT_BODY + textwrap.dedent(f'''
+    SCRIPT_BODY = ModuleSnapshot.SCRIPT_BODY + textwrap.dedent('''
         snapshot['module'].update(dict(
             int_const=mod.int_const,
             str_const=mod.str_const,
index 2f35eaf08a2dc9e0187f55cdf993fb5d028d6b43..362b507d1582889d0d48afb5b927976b7e52a6b7 100644 (file)
@@ -394,17 +394,17 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
 
     def test_filter_to_tag(self):
         company = "PythonTestSuite"
-        data = self.run_py([f"-V:3.100"])
+        data = self.run_py(["-V:3.100"])
         self.assertEqual("X.Y.exe", data["LaunchCommand"])
         self.assertEqual(company, data["env.company"])
         self.assertEqual("3.100", data["env.tag"])
 
-        data = self.run_py([f"-V:3.100-32"])
+        data = self.run_py(["-V:3.100-32"])
         self.assertEqual("X.Y-32.exe", data["LaunchCommand"])
         self.assertEqual(company, data["env.company"])
         self.assertEqual("3.100-32", data["env.tag"])
 
-        data = self.run_py([f"-V:3.100-arm64"])
+        data = self.run_py(["-V:3.100-arm64"])
         self.assertEqual("X.Y-arm64.exe -X fake_arg_for_test", data["LaunchCommand"])
         self.assertEqual(company, data["env.company"])
         self.assertEqual("3.100-arm64", data["env.tag"])
@@ -421,7 +421,7 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
     def test_filter_with_single_install(self):
         company = "PythonTestSuite1"
         data = self.run_py(
-            [f"-V:Nonexistent"],
+            ["-V:Nonexistent"],
             env={"PYLAUNCHER_LIMIT_TO_COMPANY": company},
             expect_returncode=103,
         )
@@ -500,7 +500,7 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
                     data = self.run_py(["--version"], argv=f'{argv0} --version')
                     self.assertEqual("PythonTestSuite", data["SearchInfo.company"])
                     self.assertEqual("3.100", data["SearchInfo.tag"])
-                    self.assertEqual(f'X.Y.exe --version', data["stdout"].strip())
+                    self.assertEqual("X.Y.exe --version", data["stdout"].strip())
 
     def test_py_default_in_list(self):
         data = self.run_py(["-0"], env=TEST_PY_ENV)
@@ -662,7 +662,7 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
         self.assertIn("9PJPW5LDXLZ5", cmd)
 
     def test_literal_shebang_absolute(self):
-        with self.script(f"#! C:/some_random_app -witharg") as script:
+        with self.script("#! C:/some_random_app -witharg") as script:
             data = self.run_py([script])
         self.assertEqual(
             f"C:\\some_random_app -witharg {script}",
@@ -670,7 +670,7 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
         )
 
     def test_literal_shebang_relative(self):
-        with self.script(f"#! ..\\some_random_app -witharg") as script:
+        with self.script("#! ..\\some_random_app -witharg") as script:
             data = self.run_py([script])
         self.assertEqual(
             f"{script.parent.parent}\\some_random_app -witharg {script}",
@@ -678,14 +678,14 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
         )
 
     def test_literal_shebang_quoted(self):
-        with self.script(f'#! "some random app" -witharg') as script:
+        with self.script('#! "some random app" -witharg') as script:
             data = self.run_py([script])
         self.assertEqual(
             f'"{script.parent}\\some random app" -witharg {script}',
             data["stdout"].strip(),
         )
 
-        with self.script(f'#! some" random "app -witharg') as script:
+        with self.script('#! some" random "app -witharg') as script:
             data = self.run_py([script])
         self.assertEqual(
             f'"{script.parent}\\some random app" -witharg {script}',
@@ -693,7 +693,7 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
         )
 
     def test_literal_shebang_quoted_escape(self):
-        with self.script(f'#! some\\" random "app -witharg') as script:
+        with self.script('#! some\\" random "app -witharg') as script:
             data = self.run_py([script])
         self.assertEqual(
             f'"{script.parent}\\some\\ random app" -witharg {script}',
index 01eb04b53060e92f7393376607bb8ccb2cb7ebc2..bf7fc421a9df0a8538d2759c6c4e2991d84fb7b9 100644 (file)
@@ -810,7 +810,7 @@ class TestMarkingVariablesAsUnKnown(BytecodeTestCase):
         self.assertInBytecode(f, 'LOAD_FAST', "a73")
 
     def test_setting_lineno_no_undefined(self):
-        code = textwrap.dedent(f"""\
+        code = textwrap.dedent("""\
             def f():
                 x = y = 2
                 if not x:
@@ -842,7 +842,7 @@ class TestMarkingVariablesAsUnKnown(BytecodeTestCase):
         self.assertEqual(f.__code__.co_code, co_code)
 
     def test_setting_lineno_one_undefined(self):
-        code = textwrap.dedent(f"""\
+        code = textwrap.dedent("""\
             def f():
                 x = y = 2
                 if not x:
@@ -876,7 +876,7 @@ class TestMarkingVariablesAsUnKnown(BytecodeTestCase):
         self.assertEqual(f.__code__.co_code, co_code)
 
     def test_setting_lineno_two_undefined(self):
-        code = textwrap.dedent(f"""\
+        code = textwrap.dedent("""\
             def f():
                 x = y = 2
                 if not x:
index ad83a97c8c40d69c0c75bd1e3697faf63358c54a..7e8221e7227e6e0435ef800410bc31e777ad7c96 100644 (file)
@@ -491,21 +491,21 @@ class RecursiveUseOfCursors(unittest.TestCase):
     def test_recursive_cursor_init(self):
         conv = lambda x: self.cur.__init__(self.con)
         with patch.dict(sqlite.converters, {"INIT": conv}):
-            self.cur.execute(f'select x as "x [INIT]", x from test')
+            self.cur.execute('select x as "x [INIT]", x from test')
             self.assertRaisesRegex(sqlite.ProgrammingError, self.msg,
                                    self.cur.fetchall)
 
     def test_recursive_cursor_close(self):
         conv = lambda x: self.cur.close()
         with patch.dict(sqlite.converters, {"CLOSE": conv}):
-            self.cur.execute(f'select x as "x [CLOSE]", x from test')
+            self.cur.execute('select x as "x [CLOSE]", x from test')
             self.assertRaisesRegex(sqlite.ProgrammingError, self.msg,
                                    self.cur.fetchall)
 
     def test_recursive_cursor_iter(self):
         conv = lambda x, l=[]: self.cur.fetchone() if l else l.append(None)
         with patch.dict(sqlite.converters, {"ITER": conv}):
-            self.cur.execute(f'select x as "x [ITER]", x from test')
+            self.cur.execute('select x as "x [ITER]", x from test')
             self.assertRaisesRegex(sqlite.ProgrammingError, self.msg,
                                    self.cur.fetchall)
 
index 0970b0378ad6151a5b8d0c05a82bb96d01b01aa1..632d657d416fd4f5001ace800d71e7151d2be6d1 100644 (file)
@@ -562,7 +562,7 @@ class WindowFunctionTests(unittest.TestCase):
         # callback errors to sqlite3_step(); this implies that OperationalError
         # is _not_ raised.
         with patch.object(WindowSumInt, "finalize", side_effect=BadWindow):
-            name = f"exception_in_finalize"
+            name = "exception_in_finalize"
             self.con.create_window_function(name, 1, WindowSumInt)
             self.cur.execute(self.query % name)
             self.cur.fetchall()
index a6172ff05eed47805385e38e92f18a4ed3167843..5e2b353782994e23b3156a292304fe16ffba3aff 100644 (file)
@@ -802,12 +802,12 @@ class TracebackErrorLocationCaretTestBase:
             )()
         actual = self.get_exception(f)
         expected = [
-            f"Traceback (most recent call last):",
+            "Traceback (most recent call last):",
             f"  File \"{__file__}\", line {self.callable_line}, in get_exception",
-            f"    callable()",
+            "    callable()",
             f"  File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
-            f"    .method",
-            f"     ^^^^^^",
+            "    .method",
+            "     ^^^^^^",
         ]
         self.assertEqual(actual, expected)
 
@@ -818,11 +818,11 @@ class TracebackErrorLocationCaretTestBase:
             )()
         actual = self.get_exception(f)
         expected = [
-            f"Traceback (most recent call last):",
+            "Traceback (most recent call last):",
             f"  File \"{__file__}\", line {self.callable_line}, in get_exception",
-            f"    callable()",
+            "    callable()",
             f"  File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
-            f"    method",
+            "    method",
         ]
         self.assertEqual(actual, expected)
 
@@ -833,12 +833,12 @@ class TracebackErrorLocationCaretTestBase:
             )()
         actual = self.get_exception(f)
         expected = [
-            f"Traceback (most recent call last):",
+            "Traceback (most recent call last):",
             f"  File \"{__file__}\", line {self.callable_line}, in get_exception",
-            f"    callable()",
+            "    callable()",
             f"  File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
-            f"    . method",
-            f"      ^^^^^^",
+            "    . method",
+            "      ^^^^^^",
         ]
         self.assertEqual(actual, expected)
 
@@ -848,11 +848,11 @@ class TracebackErrorLocationCaretTestBase:
 
         actual = self.get_exception(f)
         expected = [
-            f"Traceback (most recent call last):",
+            "Traceback (most recent call last):",
             f"  File \"{__file__}\", line {self.callable_line}, in get_exception",
-            f"    callable()",
+            "    callable()",
             f"  File \"{__file__}\", line {f.__code__.co_firstlineno + 1}, in f",
-            f"    width",
+            "    width",
         ]
         self.assertEqual(actual, expected)
 
@@ -864,11 +864,11 @@ class TracebackErrorLocationCaretTestBase:
 
         actual = self.get_exception(f)
         expected = [
-            f"Traceback (most recent call last):",
+            "Traceback (most recent call last):",
             f"  File \"{__file__}\", line {self.callable_line}, in get_exception",
-            f"    callable()",
+            "    callable()",
             f"  File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
-            f"    raise ValueError(width)",
+            "    raise ValueError(width)",
         ]
         self.assertEqual(actual, expected)
 
@@ -882,12 +882,12 @@ class TracebackErrorLocationCaretTestBase:
 
         actual = self.get_exception(f)
         expected = [
-            f"Traceback (most recent call last):",
+            "Traceback (most recent call last):",
             f"  File \"{__file__}\", line {self.callable_line}, in get_exception",
-            f"    callable()",
+            "    callable()",
             f"  File \"{__file__}\", line {f.__code__.co_firstlineno + 4}, in f",
-            f"    print(1, www(",
-            f"             ^^^^",
+            "    print(1, www(",
+            "             ^^^^",
         ]
         self.assertEqual(actual, expected)
 
@@ -2844,26 +2844,26 @@ class TestTracebackException_ExceptionGroups(unittest.TestCase):
         formatted = ''.join(teg.format()).split('\n')
 
         expected = [
-                    f'  | ExceptionGroup: eg (2 sub-exceptions)',
-                    f'  +-+---------------- 1 ----------------',
-                    f'    | ExceptionGroup: eg1 (3 sub-exceptions)',
-                    f'    +-+---------------- 1 ----------------',
-                    f'      | ValueError: 0',
-                    f'      +---------------- 2 ----------------',
-                    f'      | ValueError: 1',
-                    f'      +---------------- ... ----------------',
-                    f'      | and 1 more exception',
-                    f'      +------------------------------------',
-                    f'    +---------------- 2 ----------------',
-                    f'    | ExceptionGroup: eg2 (10 sub-exceptions)',
-                    f'    +-+---------------- 1 ----------------',
-                    f'      | TypeError: 0',
-                    f'      +---------------- 2 ----------------',
-                    f'      | TypeError: 1',
-                    f'      +---------------- ... ----------------',
-                    f'      | and 8 more exceptions',
-                    f'      +------------------------------------',
-                    f'']
+                    '  | ExceptionGroup: eg (2 sub-exceptions)',
+                    '  +-+---------------- 1 ----------------',
+                    '    | ExceptionGroup: eg1 (3 sub-exceptions)',
+                    '    +-+---------------- 1 ----------------',
+                    '      | ValueError: 0',
+                    '      +---------------- 2 ----------------',
+                    '      | ValueError: 1',
+                    '      +---------------- ... ----------------',
+                    '      | and 1 more exception',
+                    '      +------------------------------------',
+                    '    +---------------- 2 ----------------',
+                    '    | ExceptionGroup: eg2 (10 sub-exceptions)',
+                    '    +-+---------------- 1 ----------------',
+                    '      | TypeError: 0',
+                    '      +---------------- 2 ----------------',
+                    '      | TypeError: 1',
+                    '      +---------------- ... ----------------',
+                    '      | and 8 more exceptions',
+                    '      +------------------------------------',
+                    '']
 
         self.assertEqual(formatted, expected)
 
@@ -2876,22 +2876,22 @@ class TestTracebackException_ExceptionGroups(unittest.TestCase):
         formatted = ''.join(teg.format()).split('\n')
 
         expected = [
-                    f'  | ExceptionGroup: exc (3 sub-exceptions)',
-                    f'  +-+---------------- 1 ----------------',
-                    f'    | ValueError: -2',
-                    f'    +---------------- 2 ----------------',
-                    f'    | ExceptionGroup: exc (3 sub-exceptions)',
-                    f'    +-+---------------- 1 ----------------',
-                    f'      | ValueError: -1',
-                    f'      +---------------- 2 ----------------',
-                    f'      | ... (max_group_depth is 2)',
-                    f'      +---------------- 3 ----------------',
-                    f'      | ValueError: 1',
-                    f'      +------------------------------------',
-                    f'    +---------------- 3 ----------------',
-                    f'    | ValueError: 2',
-                    f'    +------------------------------------',
-                    f'']
+                    '  | ExceptionGroup: exc (3 sub-exceptions)',
+                    '  +-+---------------- 1 ----------------',
+                    '    | ValueError: -2',
+                    '    +---------------- 2 ----------------',
+                    '    | ExceptionGroup: exc (3 sub-exceptions)',
+                    '    +-+---------------- 1 ----------------',
+                    '      | ValueError: -1',
+                    '      +---------------- 2 ----------------',
+                    '      | ... (max_group_depth is 2)',
+                    '      +---------------- 3 ----------------',
+                    '      | ValueError: 1',
+                    '      +------------------------------------',
+                    '    +---------------- 3 ----------------',
+                    '    | ValueError: 2',
+                    '    +------------------------------------',
+                    '']
 
         self.assertEqual(formatted, expected)