Skip to content

Commit 63ebba0

Browse files
bpo-43013: Update idlelib code to 3.x (GH-24315) (#24317)
Remove 9 remaining '(object)' occurrences in class headers in idlelib and 25 '()' occurrences in idlelib.idle_test class headers. (cherry picked from commit 8dfe156) Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent dce86c2 commit 63ebba0

10 files changed

+49
-47
lines changed

Lib/idlelib/editor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _sphinx_version():
4646
return release
4747

4848

49-
class EditorWindow(object):
49+
class EditorWindow:
5050
from idlelib.percolator import Percolator
5151
from idlelib.colorizer import ColorDelegator, color_config
5252
from idlelib.undo import UndoDelegator
@@ -1546,7 +1546,7 @@ def get_line_indent(line, tabwidth):
15461546
return m.end(), len(m.group().expandtabs(tabwidth))
15471547

15481548

1549-
class IndentSearcher(object):
1549+
class IndentSearcher:
15501550

15511551
# .run() chews over the Text widget, looking for a block opener
15521552
# and the stmt following it. Returns a pair,

Lib/idlelib/idle_test/test_autocomplete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def test_open_completions_none(self):
195195
self.assertFalse(acp.open_completions(ac.TAB))
196196
self.text.delete('1.0', 'end')
197197

198-
class dummy_acw():
198+
class dummy_acw:
199199
__init__ = Func()
200200
show_window = Func(result=False)
201201
hide_window = Func()

Lib/idlelib/idle_test/test_calltip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
# Test Class TC is used in multiple get_argspec test methods
13-
class TC():
13+
class TC:
1414
'doc'
1515
tip = "(ai=None, *b)"
1616
def __init__(self, ai=None, *b): 'doc'
@@ -268,7 +268,7 @@ def test_good_entity(self):
268268
# open_calltip is about half the code; the others are fairly trivial.
269269
# The default mocks are what are needed for open_calltip.
270270

271-
class mock_Shell():
271+
class mock_Shell:
272272
"Return mock sufficient to pass to hyperparser."
273273
def __init__(self, text):
274274
text.tag_prevrange = Mock(return_value=None)

Lib/idlelib/idle_test/test_codecontext.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
code_sample = """\
2222
23-
class C1():
23+
class C1:
2424
# Class comment.
2525
def __init__(self, a, b):
2626
self.a = a
@@ -178,29 +178,29 @@ def test_get_context(self):
178178
with self.assertRaises(AssertionError):
179179
gc(1, stopline=0)
180180

181-
eq(gc(3), ([(2, 0, 'class C1():', 'class')], 0))
181+
eq(gc(3), ([(2, 0, 'class C1:', 'class')], 0))
182182

183183
# Don't return comment.
184-
eq(gc(4), ([(2, 0, 'class C1():', 'class')], 0))
184+
eq(gc(4), ([(2, 0, 'class C1:', 'class')], 0))
185185

186186
# Two indentation levels and no comment.
187-
eq(gc(5), ([(2, 0, 'class C1():', 'class'),
187+
eq(gc(5), ([(2, 0, 'class C1:', 'class'),
188188
(4, 4, ' def __init__(self, a, b):', 'def')], 0))
189189

190190
# Only one 'def' is returned, not both at the same indent level.
191-
eq(gc(10), ([(2, 0, 'class C1():', 'class'),
191+
eq(gc(10), ([(2, 0, 'class C1:', 'class'),
192192
(7, 4, ' def compare(self):', 'def'),
193193
(8, 8, ' if a > b:', 'if')], 0))
194194

195195
# With 'elif', also show the 'if' even though it's at the same level.
196-
eq(gc(11), ([(2, 0, 'class C1():', 'class'),
196+
eq(gc(11), ([(2, 0, 'class C1:', 'class'),
197197
(7, 4, ' def compare(self):', 'def'),
198198
(8, 8, ' if a > b:', 'if'),
199199
(10, 8, ' elif a < b:', 'elif')], 0))
200200

201201
# Set stop_line to not go back to first line in source code.
202202
# Return includes stop_line.
203-
eq(gc(11, stopline=2), ([(2, 0, 'class C1():', 'class'),
203+
eq(gc(11, stopline=2), ([(2, 0, 'class C1:', 'class'),
204204
(7, 4, ' def compare(self):', 'def'),
205205
(8, 8, ' if a > b:', 'if'),
206206
(10, 8, ' elif a < b:', 'elif')], 0))
@@ -240,37 +240,37 @@ def test_update_code_context(self):
240240
# Scroll down to line 2.
241241
cc.text.yview(2)
242242
cc.update_code_context()
243-
eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')])
243+
eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1:', 'class')])
244244
eq(cc.topvisible, 3)
245-
eq(cc.context.get('1.0', 'end-1c'), 'class C1():')
245+
eq(cc.context.get('1.0', 'end-1c'), 'class C1:')
246246

247247
# Scroll down to line 3. Since it's a comment, nothing changes.
248248
cc.text.yview(3)
249249
cc.update_code_context()
250-
eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')])
250+
eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1:', 'class')])
251251
eq(cc.topvisible, 4)
252-
eq(cc.context.get('1.0', 'end-1c'), 'class C1():')
252+
eq(cc.context.get('1.0', 'end-1c'), 'class C1:')
253253

254254
# Scroll down to line 4.
255255
cc.text.yview(4)
256256
cc.update_code_context()
257257
eq(cc.info, [(0, -1, '', False),
258-
(2, 0, 'class C1():', 'class'),
258+
(2, 0, 'class C1:', 'class'),
259259
(4, 4, ' def __init__(self, a, b):', 'def')])
260260
eq(cc.topvisible, 5)
261-
eq(cc.context.get('1.0', 'end-1c'), 'class C1():\n'
261+
eq(cc.context.get('1.0', 'end-1c'), 'class C1:\n'
262262
' def __init__(self, a, b):')
263263

264264
# Scroll down to line 11. Last 'def' is removed.
265265
cc.text.yview(11)
266266
cc.update_code_context()
267267
eq(cc.info, [(0, -1, '', False),
268-
(2, 0, 'class C1():', 'class'),
268+
(2, 0, 'class C1:', 'class'),
269269
(7, 4, ' def compare(self):', 'def'),
270270
(8, 8, ' if a > b:', 'if'),
271271
(10, 8, ' elif a < b:', 'elif')])
272272
eq(cc.topvisible, 12)
273-
eq(cc.context.get('1.0', 'end-1c'), 'class C1():\n'
273+
eq(cc.context.get('1.0', 'end-1c'), 'class C1:\n'
274274
' def compare(self):\n'
275275
' if a > b:\n'
276276
' elif a < b:')
@@ -279,12 +279,12 @@ def test_update_code_context(self):
279279
cc.update_code_context()
280280
cc.context_depth = 1
281281
eq(cc.info, [(0, -1, '', False),
282-
(2, 0, 'class C1():', 'class'),
282+
(2, 0, 'class C1:', 'class'),
283283
(7, 4, ' def compare(self):', 'def'),
284284
(8, 8, ' if a > b:', 'if'),
285285
(10, 8, ' elif a < b:', 'elif')])
286286
eq(cc.topvisible, 12)
287-
eq(cc.context.get('1.0', 'end-1c'), 'class C1():\n'
287+
eq(cc.context.get('1.0', 'end-1c'), 'class C1:\n'
288288
' def compare(self):\n'
289289
' if a > b:\n'
290290
' elif a < b:')
@@ -293,7 +293,7 @@ def test_update_code_context(self):
293293
cc.text.yview(5)
294294
cc.update_code_context()
295295
eq(cc.info, [(0, -1, '', False),
296-
(2, 0, 'class C1():', 'class'),
296+
(2, 0, 'class C1:', 'class'),
297297
(4, 4, ' def __init__(self, a, b):', 'def')])
298298
eq(cc.topvisible, 6)
299299
# context_depth is 1.
@@ -440,7 +440,7 @@ def test_get_line_info(self):
440440
# Line 1 is not a BLOCKOPENER.
441441
eq(gli(lines[0]), (codecontext.INFINITY, '', False))
442442
# Line 2 is a BLOCKOPENER without an indent.
443-
eq(gli(lines[1]), (0, 'class C1():', 'class'))
443+
eq(gli(lines[1]), (0, 'class C1:', 'class'))
444444
# Line 3 is not a BLOCKOPENER and does not return the indent level.
445445
eq(gli(lines[2]), (codecontext.INFINITY, ' # Class comment.', False))
446446
# Line 4 is a BLOCKOPENER and is indented.

Lib/idlelib/idle_test/test_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def tearDown(self):
418418

419419
code_sample = """\
420420
# WS line needed for test.
421-
class C1():
421+
class C1:
422422
# Class comment.
423423
def __init__(self, a, b):
424424
self.a = a

Lib/idlelib/idle_test/test_help_about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_close(self):
134134
self.dialog.winfo_class()
135135

136136

137-
class Dummy_about_dialog():
137+
class Dummy_about_dialog:
138138
# Dummy class for testing file display functions.
139139
idle_credits = About.show_idle_credits
140140
idle_readme = About.show_readme

Lib/idlelib/idle_test/test_pyparse.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ def char_in_string_false(index): return False
7373

7474
# Split def across lines.
7575
setcode('"""This is a module docstring"""\n'
76-
'class C():\n'
76+
'class C:\n'
7777
' def __init__(self, a,\n'
7878
' b=True):\n'
7979
' pass\n'
8080
)
81+
pos0, pos = 33, 42 # Start of 'class...', ' def' lines.
8182

8283
# Passing no value or non-callable should fail (issue 32989).
8384
with self.assertRaises(TypeError):
@@ -91,40 +92,41 @@ def char_in_string_false(index): return False
9192

9293
# Make all text look like it's not in a string. This means that it
9394
# found a good start position.
94-
eq(start(char_in_string_false), 44)
95+
eq(start(char_in_string_false), pos)
9596

9697
# If the beginning of the def line is not in a string, then it
9798
# returns that as the index.
98-
eq(start(is_char_in_string=lambda index: index > 44), 44)
99+
eq(start(is_char_in_string=lambda index: index > pos), pos)
99100
# If the beginning of the def line is in a string, then it
100101
# looks for a previous index.
101-
eq(start(is_char_in_string=lambda index: index >= 44), 33)
102+
eq(start(is_char_in_string=lambda index: index >= pos), pos0)
102103
# If everything before the 'def' is in a string, then returns None.
103104
# The non-continuation def line returns 44 (see below).
104-
eq(start(is_char_in_string=lambda index: index < 44), None)
105+
eq(start(is_char_in_string=lambda index: index < pos), None)
105106

106107
# Code without extra line break in def line - mostly returns the same
107108
# values.
108109
setcode('"""This is a module docstring"""\n'
109-
'class C():\n'
110+
'class C:\n'
110111
' def __init__(self, a, b=True):\n'
111112
' pass\n'
112-
)
113-
eq(start(char_in_string_false), 44)
114-
eq(start(is_char_in_string=lambda index: index > 44), 44)
115-
eq(start(is_char_in_string=lambda index: index >= 44), 33)
113+
) # Does not affect class, def positions.
114+
eq(start(char_in_string_false), pos)
115+
eq(start(is_char_in_string=lambda index: index > pos), pos)
116+
eq(start(is_char_in_string=lambda index: index >= pos), pos0)
116117
# When the def line isn't split, this returns which doesn't match the
117118
# split line test.
118-
eq(start(is_char_in_string=lambda index: index < 44), 44)
119+
eq(start(is_char_in_string=lambda index: index < pos), pos)
119120

120121
def test_set_lo(self):
121122
code = (
122123
'"""This is a module docstring"""\n'
123-
'class C():\n'
124+
'class C:\n'
124125
' def __init__(self, a,\n'
125126
' b=True):\n'
126127
' pass\n'
127128
)
129+
pos = 42
128130
p = self.parser
129131
p.set_code(code)
130132

@@ -137,8 +139,8 @@ def test_set_lo(self):
137139
self.assertEqual(p.code, code)
138140

139141
# An index that is preceded by a newline.
140-
p.set_lo(44)
141-
self.assertEqual(p.code, code[44:])
142+
p.set_lo(pos)
143+
self.assertEqual(p.code, code[pos:])
142144

143145
def test_study1(self):
144146
eq = self.assertEqual

Lib/idlelib/rpc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def handle_error(self, request, client_address):
125125
response_queue = queue.Queue(0)
126126

127127

128-
class SocketIO(object):
128+
class SocketIO:
129129

130130
nextseq = 0
131131

@@ -486,7 +486,7 @@ def EOFhook(self):
486486

487487
#----------------- end class SocketIO --------------------
488488

489-
class RemoteObject(object):
489+
class RemoteObject:
490490
# Token mix-in class
491491
pass
492492

@@ -497,7 +497,7 @@ def remoteref(obj):
497497
return RemoteProxy(oid)
498498

499499

500-
class RemoteProxy(object):
500+
class RemoteProxy:
501501

502502
def __init__(self, oid):
503503
self.oid = oid
@@ -547,7 +547,7 @@ def get_remote_proxy(self, oid):
547547
return RPCProxy(self, oid)
548548

549549

550-
class RPCProxy(object):
550+
class RPCProxy:
551551

552552
__methods = None
553553
__attributes = None
@@ -596,7 +596,7 @@ def _getattributes(obj, attributes):
596596
attributes[name] = 1
597597

598598

599-
class MethodProxy(object):
599+
class MethodProxy:
600600

601601
def __init__(self, sockio, oid, name):
602602
self.sockio = sockio

Lib/idlelib/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def decode_interrupthook(self):
538538
thread.interrupt_main()
539539

540540

541-
class Executive(object):
541+
class Executive:
542542

543543
def __init__(self, rpchandler):
544544
self.rpchandler = rpchandler

Lib/idlelib/tooltip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from tkinter import *
88

99

10-
class TooltipBase(object):
10+
class TooltipBase:
1111
"""abstract base class for tooltips"""
1212

1313
def __init__(self, anchor_widget):

0 commit comments

Comments
 (0)