Skip to content
Open
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
14 changes: 8 additions & 6 deletions Lib/idlelib/config_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@

# Basic entry help text.
help_basic = Label(self.frame_controls_basic, justify='left',
text="Select the desired modifier keys\n"+
"above, and the final key from the\n"+
"list on the right.\n\n" +
"Use upper case Symbols when using\n" +
"the Shift modifier. (Letters will be\n" +
"converted automatically.)")
text=d"""
Select the desired modifier keys
above, and the final key from the
list on the right.

Use upper case Symbols when using
the Shift modifier. (Letters will be
converted automatically.)""")

Check failure on line 119 in Lib/idlelib/config_key.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/config_key.py:112:34: invalid-syntax: Expected `,`, found string

Check failure on line 119 in Lib/idlelib/config_key.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/config_key.py:112:34: invalid-syntax: Expected `,`, found string
help_basic.grid(row=1, column=0, columnspan=4, padx=2, sticky='w')

# Basic entry key list.
Expand Down
9 changes: 4 additions & 5 deletions Lib/idlelib/idle_test/htest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@

import idlelib.pyshell # Set Windows DPI awareness before Tk().
from importlib import import_module
import textwrap
import tkinter as tk
from tkinter.ttk import Scrollbar
tk.NoDefaultRoot()
Expand Down Expand Up @@ -215,11 +214,11 @@
_module_browser_spec = {
'file': 'browser',
'kwds': {},
'msg': textwrap.dedent("""
'msg': d"""
"Inspect names of module, class(with superclass if applicable),
"methods and functions. Toggle nested items. Double clicking
"on items prints a traceback for an exception that is ignored.""")
"on items prints a traceback for an exception that is ignored."""

Check failure on line 220 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:217:13: invalid-syntax: Expected `,`, found string

Check failure on line 220 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:217:13: invalid-syntax: Expected `,`, found string
}

Check failure on line 221 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:221:5: invalid-syntax: Expected `:`, found `}`

Check failure on line 221 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:221:5: invalid-syntax: Expected `:`, found `}`

_multistatus_bar_spec = {
'file': 'statusbar',
Expand Down Expand Up @@ -302,21 +301,21 @@
_sidebar_number_scrolling_spec = {
'file': 'sidebar',
'kwds': {},
'msg': textwrap.dedent("""\
'msg': d"""
1. Click on the line numbers and drag down below the edge of the
window, moving the mouse a bit and then leaving it there for a
while. The text and line numbers should gradually scroll down,
with the selection updated continuously.

2. With the lines still selected, click on a line number above
or below the selected lines. Only the line whose number was
clicked should be selected.

3. Repeat step #1, dragging to above the window. The text and
line numbers should gradually scroll up, with the selection
updated continuously.

4. Repeat step #2, clicking a line number below the selection."""),
4. Repeat step #2, clicking a line number below the selection.""",

Check failure on line 318 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:318:74: invalid-syntax: Expected `:`, found `,`

Check failure on line 318 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:304:13: invalid-syntax: Expected `,`, found string

Check failure on line 318 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:318:74: invalid-syntax: Expected `:`, found `,`

Check failure on line 318 in Lib/idlelib/idle_test/htest.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/htest.py:304:13: invalid-syntax: Expected `,`, found string
}

_stackbrowser_spec = {
Expand Down
9 changes: 4 additions & 5 deletions Lib/idlelib/idle_test/test_colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from idlelib.idle_test.tkinter_testing_utils import run_in_tk_mainloop

from functools import partial
import textwrap
from tkinter import Tk, Text
from idlelib import config
from idlelib.percolator import Percolator
Expand All @@ -20,39 +19,39 @@
'extensions': config.IdleUserConfParser(''),
}

source = textwrap.dedent("""\
source = d"""
if True: int ('1') # keyword, builtin, string, comment
elif False: print(0) # 'string' in comment
else: float(None) # if in comment
if iF + If + IF: 'keyword matching must respect case'
if'': x or'' # valid keyword-string no-space combinations
async def f(): await g()
# Strings should be entirely colored, including quotes.
'x', '''x''', "x", \"""x\"""
'abc\\
def'
'''abc\\
def'''
# All valid prefixes for unicode and byte strings should be colored.
r'x', u'x', R'x', U'x', f'x', F'x'
fr'x', Fr'x', fR'x', FR'x', rf'x', rF'x', Rf'x', RF'x'
tr'x', Tr'x', tR'x', TR'x', rt'x', rT'x', Rt'x', RT'x'
b'x',B'x', br'x',Br'x',bR'x',BR'x', rb'x', rB'x',Rb'x',RB'x'
# Invalid combinations of legal characters should be half colored.
ur'x', ru'x', uf'x', fu'x', UR'x', ufr'x', rfu'x', xf'x', fx'x'
match point:
case (x, 0) as _:
print(f"X={x}")
case [_, [_], "_",
_]:
pass
case _ if ("a" if _ else set()): pass
case _:
raise ValueError("Not a point _")
'''
case _:'''
"match x:"
""")
"""

Check failure on line 54 in Lib/idlelib/idle_test/test_colorizer.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/test_colorizer.py:22:11: invalid-syntax: Simple statements must be separated by newlines or semicolons

Check failure on line 54 in Lib/idlelib/idle_test/test_colorizer.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/test_colorizer.py:22:11: invalid-syntax: Simple statements must be separated by newlines or semicolons


def setUpModule():
Expand Down Expand Up @@ -561,13 +560,13 @@
self._assert_highlighting('lazy foo', {})

def test_long_multiline_string(self):
source = textwrap.dedent('''\
source = d'''
"""a
b
c
d
e"""
''')
'''

Check failure on line 569 in Lib/idlelib/idle_test/test_colorizer.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/test_colorizer.py:563:19: invalid-syntax: Simple statements must be separated by newlines or semicolons

Check failure on line 569 in Lib/idlelib/idle_test/test_colorizer.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/idle_test/test_colorizer.py:563:19: invalid-syntax: Simple statements must be separated by newlines or semicolons
self._assert_highlighting(source, {'STRING': [('1.0', '5.4')]})

@run_in_tk_mainloop(delay=50)
Expand Down
8 changes: 4 additions & 4 deletions Lib/idlelib/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,21 +481,21 @@
thread.interrupt_main()
except:
erf = sys.__stderr__
print(textwrap.dedent(f"""
print(fd"""
{'-'*40}
Unhandled exception in user code execution server!'
Thread: {threading.current_thread().name}
IDLE Client Address: {client_address}
Request: {request!r}
"""), file=erf)
""", file=erf)

Check failure on line 490 in Lib/idlelib/run.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/run.py:484:21: invalid-syntax: Expected `,`, found string

Check failure on line 490 in Lib/idlelib/run.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/run.py:484:21: invalid-syntax: Expected `,`, found string
traceback.print_exc(limit=-20, file=erf)
print(textwrap.dedent(f"""
print(fd"""
*** Unrecoverable, server exiting!

Users should never see this message; it is likely transient.
If this recurs, report this with a copy of the message
and an explanation of how to make it repeat.
{'-'*40}"""), file=erf)
{'-'*40}""", file=erf)

Check failure on line 498 in Lib/idlelib/run.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/run.py:492:21: invalid-syntax: Expected `,`, found string

Check failure on line 498 in Lib/idlelib/run.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/idlelib/run.py:492:21: invalid-syntax: Expected `,`, found string
quitting = True
thread.interrupt_main()

Expand Down
5 changes: 1 addition & 4 deletions Lib/importlib/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import posixpath
import re
import sys
import textwrap
import types
from collections.abc import Iterable, Mapping
from contextlib import suppress
Expand Down Expand Up @@ -101,17 +100,15 @@
[]
"""

_sample = textwrap.dedent(
"""
_sample = d"""
[sec1]
# comments ignored
a = 1
b = 2

[sec2]
a = 2
"""

Check failure on line 111 in Lib/importlib/metadata/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/importlib/metadata/__init__.py:103:16: invalid-syntax: Simple statements must be separated by newlines or semicolons

Check failure on line 111 in Lib/importlib/metadata/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/importlib/metadata/__init__.py:103:16: invalid-syntax: Simple statements must be separated by newlines or semicolons
).lstrip()

@classmethod
def section_pairs(cls, text):
Expand Down
35 changes: 16 additions & 19 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3621,12 +3621,11 @@ def _connect(
elif version != remote_pdb.protocol_version():
target_ver = f"0x{remote_pdb.protocol_version():08X}"
attach_ver = f"0x{version:08X}"
remote_pdb.error(
f"The target process is running a Python version that is"
f" incompatible with this PDB module."
f"\nTarget process pdb protocol version: {target_ver}"
f"\nLocal pdb module's protocol version: {attach_ver}"
)
remote_pdb.error(df"""
The target process is running a Python version that is\
incompatible with this PDB module.
Target process pdb protocol version: {target_ver}
Local pdb module's protocol version: {attach_ver}""")
else:
remote_pdb.set_trace(frame=frame, commands=commands.splitlines())

Expand All @@ -3647,20 +3646,18 @@ def attach(pid, commands=()):
colorize = _colorize.can_colorize()

connect_script.write(
textwrap.dedent(
f"""
import pdb, sys
pdb._connect(
host="localhost",
port={port},
frame=sys._getframe(1),
commands={json.dumps("\n".join(commands))},
version={_PdbServer.protocol_version()},
signal_raising_thread={use_signal_thread!r},
colorize={colorize!r},
)
"""
fd"""
import pdb, sys
pdb._connect(
host="localhost",
port={port},
frame=sys._getframe(1),
commands={json.dumps("\n".join(commands))},
version={_PdbServer.protocol_version()},
signal_raising_thread={use_signal_thread!r},
colorize={colorize!r},
)
"""
)
connect_script.close()
orig_mode = os.stat(connect_script.name).st_mode
Expand Down
4 changes: 2 additions & 2 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ def _introdoc():
F1: enter interactive help, F2: enter history browsing mode, F3: enter paste
mode (press again to exit).
'''
return textwrap.dedent(f'''\
return fd'''
Welcome to Python {ver}'s help utility! If this is your first time using
Python, you should definitely check out the tutorial at
https://docs.python.org/{ver}/tutorial/.
Expand All @@ -1819,7 +1819,7 @@ def _introdoc():

To quit this help utility and return to the interpreter,
enter "q", "quit" or "exit".
''')
'''

class Helper:

Expand Down
32 changes: 16 additions & 16 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6453,7 +6453,7 @@ def test_resource_tracker_mp_fork_reuse_and_prompt_reap(self):
# tracker (the at-fork handler preserves the inherited pipe fd),
# *and* the parent should be able to reap the tracker promptly
# after joining the child, without hitting the waitpid timeout.
cmd = textwrap.dedent('''
cmd = d'''
import multiprocessing as mp
from multiprocessing.resource_tracker import _resource_tracker

Expand Down Expand Up @@ -6485,7 +6485,7 @@ def child(conn):
print(child_has_fd, child_pid_none, child_alive,
_resource_tracker._waitpid_timed_out,
_resource_tracker._exitcode)
''')
'''
rc, out, err = script_helper.assert_python_ok('-c', cmd)
parts = out.decode().split()
self.assertEqual(parts, ['True', 'True', 'True', 'False', '0'],
Expand All @@ -6497,7 +6497,7 @@ def test_resource_tracker_raw_fork_prompt_reap(self):
# child's inherited fd, so the parent can reap the tracker
# immediately -- even while the child is still alive -- rather
# than waiting out the 1s timeout.
cmd = textwrap.dedent('''
cmd = d'''
import os, signal
from multiprocessing.resource_tracker import _resource_tracker

Expand All @@ -6524,7 +6524,7 @@ def test_resource_tracker_raw_fork_prompt_reap(self):
print(child_fd_closed,
_resource_tracker._waitpid_timed_out,
_resource_tracker._exitcode)
''')
'''
rc, out, err = script_helper.assert_python_ok('-c', cmd)
parts = out.decode().split()
self.assertEqual(parts, ['True', 'False', '0'],
Expand All @@ -6535,7 +6535,7 @@ def test_resource_tracker_lock_reinit_after_fork(self):
# gh-146313: If a parent thread held the tracker's lock at fork
# time, the child would inherit the held lock and deadlock on
# its next ensure_running(). The at-fork handler reinits it.
cmd = textwrap.dedent('''
cmd = d'''
import os, threading
from multiprocessing.resource_tracker import _resource_tracker

Expand All @@ -6558,7 +6558,7 @@ def hold():
t.join()
_, status = os.waitpid(pid, 0)
print(os.waitstatus_to_exitcode(status))
''')
'''
rc, out, err = script_helper.assert_python_ok(
'-W', 'ignore::DeprecationWarning', '-c', cmd)
self.assertEqual(out.strip(), b'0',
Expand All @@ -6570,7 +6570,7 @@ def test_resource_tracker_safety_net_timeout(self):
# fd and the parent calls _stop() without joining (simulating
# abnormal shutdown), the safety-net timeout should fire rather
# than deadlocking.
cmd = textwrap.dedent('''
cmd = d'''
import multiprocessing as mp
import signal
from multiprocessing.resource_tracker import _resource_tracker
Expand All @@ -6585,7 +6585,7 @@ def test_resource_tracker_safety_net_timeout(self):
print(_resource_tracker._waitpid_timed_out)
p.terminate()
p.join()
''')
'''
rc, out, err = script_helper.assert_python_ok('-c', cmd)
self.assertEqual(out.strip(), b'True',
f"safety-net timeout did not fire: stderr={err!r}")
Expand Down Expand Up @@ -7146,7 +7146,7 @@ def test_global_named_resource_spawn(self):
testfn = os_helper.TESTFN
self.addCleanup(os_helper.unlink, testfn)
with open(testfn, 'w', encoding='utf-8') as f:
f.write(textwrap.dedent('''\
f.write(d'''
import multiprocessing as mp
ctx = mp.get_context('spawn')
global_resource = ctx.Semaphore()
Expand All @@ -7155,7 +7155,7 @@ def submain(): pass
p = ctx.Process(target=submain)
p.start()
p.join()
'''))
''')
rc, out, err = script_helper.assert_python_ok(testfn)
# on error, err = 'UserWarning: resource_tracker: There appear to
# be 1 leaked semaphore objects to clean up at shutdown'
Expand Down Expand Up @@ -7301,13 +7301,13 @@ def test_large_pool(self):
testfn = os_helper.TESTFN
self.addCleanup(os_helper.unlink, testfn)
with open(testfn, 'w', encoding='utf-8') as f:
f.write(textwrap.dedent('''\
f.write(d'''
import multiprocessing
def f(x): return x*x
if __name__ == '__main__':
with multiprocessing.Pool(200) as p:
print(sum(p.map(f, range(1000))))
'''))
''')
rc, out, err = script_helper.assert_python_ok(testfn)
self.assertEqual("332833500", out.decode('utf-8').strip())
self.assertFalse(err, msg=err.decode('utf-8'))
Expand Down Expand Up @@ -7638,7 +7638,7 @@ class SemLock(_multiprocessing.SemLock):
class ForkInThreads(unittest.TestCase):

def test_fork(self):
code = """
code = d"""
import os, sys, threading, time

t = threading.Thread(target=time.sleep, args=(1,), daemon=True)
Expand Down Expand Up @@ -7666,7 +7666,7 @@ def test_fork(self):
self.assertIn(b'is multi-threaded, use of fork() may lead to deadlocks in the child', res.err)

def test_forkpty(self):
code = """
code = d"""
import os, sys, threading, time

t = threading.Thread(target=time.sleep, args=(1,), daemon=True)
Expand Down Expand Up @@ -7698,7 +7698,7 @@ class TestSharedMemoryNames(unittest.TestCase):
def test_that_shared_memory_name_with_colons_has_no_resource_tracker_errors(
self, use_simple_format):
# Test script that creates and cleans up shared memory with colon in name
test_script = textwrap.dedent("""
test_script = d"""
import sys
from multiprocessing import shared_memory
from multiprocessing import resource_tracker
Expand Down Expand Up @@ -7733,7 +7733,7 @@ def test_that_shared_memory_name_with_colons_has_no_resource_tracker_errors(
sys.exit(1)

print("SUCCESS")
""" % use_simple_format)
""" % use_simple_format

rc, out, err = assert_python_ok("-c", test_script)
self.assertIn(b"SUCCESS", out)
Expand Down
Loading