Skip to content

GH-103805: Lib test f541 linting issue fix #103812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Lib/test/test__xxinterpchannels.py
Original file line number Diff line number Diff line change
Expand Up @@ -1469,19 +1469,19 @@ def _assert_closed_in_interp(self, fix, interp=None):
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)
""")
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test__xxsubinterpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def test_shared_overwrites(self):
"""))

shared = {'spam': b'ham'}
script = dedent(f"""
script = dedent("""
ns2 = dict(vars())
del ns2['__builtins__']
""")
Expand Down Expand Up @@ -902,7 +902,7 @@ def test_execution_namespace_is_main(self):
# 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
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ def callback():
@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():
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def foo():
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()

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ def test_Set_from_iterable(self):
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)

Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_coroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2365,15 +2365,15 @@ def check(depth, msg):
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:
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,8 @@ class Point:
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:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def run_embedded_interpreter(self, *args, env=None,
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" %
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ def from_module(cls, mod):
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,
Expand Down
20 changes: 10 additions & 10 deletions Lib/test/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,17 @@ def test_filter_to_company_with_default(self):

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"])
Expand All @@ -421,7 +421,7 @@ def test_filter_to_company_and_tag(self):
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,
)
Expand Down Expand Up @@ -500,7 +500,7 @@ def test_py_default_short_argv0(self):
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)
Expand Down Expand Up @@ -662,38 +662,38 @@ def test_install(self):
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}",
data["stdout"].strip(),
)

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}",
data["stdout"].strip(),
)

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}',
data["stdout"].strip(),
)

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}',
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_peepholer.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def f():
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:
Expand Down Expand Up @@ -842,7 +842,7 @@ def trace(frame, event, arg):
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:
Expand Down Expand Up @@ -876,7 +876,7 @@ def trace(frame, event, arg):
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:
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_sqlite3/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,21 +491,21 @@ def tearDown(self):
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)

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_sqlite3/test_userfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def test_win_exception_in_finalize(self):
# 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()
Expand Down
Loading