Skip to content

Commit e97a685

Browse files
authored
[3.6] bpo-33907: Rename an IDLE module and class. (GH-7807) (GH-7809)
Improve consistency and appearance. Module idlelib.calltips is now calltip. Class idlelib.calltip_w.CallTip is now Calltip. (cherry picked from commit 06e2029) Co-authored-by: Terry Jan Reedy <[email protected]>
1 parent 90209a1 commit e97a685

File tree

7 files changed

+33
-30
lines changed

7 files changed

+33
-30
lines changed

Lib/idlelib/calltips.py renamed to Lib/idlelib/calltip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import __main__
1616

1717

18-
class CallTips:
18+
class Calltip:
1919

2020
def __init__(self, editwin=None):
2121
if editwin is None: # subprocess and test
@@ -31,7 +31,7 @@ def close(self):
3131

3232
def _make_tk_calltip_window(self):
3333
# See __init__ for usage
34-
return calltip_w.CallTip(self.text)
34+
return calltip_w.Calltip(self.text)
3535

3636
def _remove_calltip_window(self, event=None):
3737
if self.active_calltip:
@@ -44,7 +44,7 @@ def force_open_calltip_event(self, event):
4444
return "break"
4545

4646
def try_open_calltip_event(self, event):
47-
"""Happens when it would be nice to open a CallTip, but not really
47+
"""Happens when it would be nice to open a Calltip, but not really
4848
necessary, for example after an opening bracket, so function calls
4949
won't be made.
5050
"""
@@ -175,4 +175,4 @@ def get_argspec(ob):
175175

176176
if __name__ == '__main__':
177177
from unittest import main
178-
main('idlelib.idle_test.test_calltips', verbosity=2)
178+
main('idlelib.idle_test.test_calltip', verbosity=2)

Lib/idlelib/calltip_w.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""A CallTip window class for Tkinter/IDLE.
1+
"""A Calltip window class for Tkinter/IDLE.
22
33
After tooltip.py, which uses ideas gleaned from PySol
4-
Used by the calltips IDLE extension.
4+
Used by calltip.
55
"""
66
from tkinter import Toplevel, Label, LEFT, SOLID, TclError
77

@@ -13,7 +13,7 @@
1313

1414
MARK_RIGHT = "calltipwindowregion_right"
1515

16-
class CallTip:
16+
class Calltip:
1717

1818
def __init__(self, widget):
1919
self.widget = widget
@@ -47,7 +47,7 @@ def position_window(self):
4747
def showtip(self, text, parenleft, parenright):
4848
"""Show the calltip, bind events which will close it and reposition it.
4949
"""
50-
# Only called in CallTips, where lines are truncated
50+
# Only called in Calltip, where lines are truncated
5151
self.text = text
5252
if self.tipwindow or not self.text:
5353
return
@@ -147,7 +147,7 @@ def _calltip_window(parent): # htest #
147147
text.pack(side=LEFT, fill=BOTH, expand=1)
148148
text.insert("insert", "string.split")
149149
top.update()
150-
calltip = CallTip(text)
150+
calltip = Calltip(text)
151151

152152
def calltip_show(event):
153153
calltip.showtip("(s=Hello world)", "insert", "end")
@@ -161,7 +161,7 @@ def calltip_hide(event):
161161

162162
if __name__ == '__main__':
163163
from unittest import main
164-
main('idlelib.idle_test.test_calltips', verbosity=2, exit=False)
164+
main('idlelib.idle_test.test_calltip_w', verbosity=2, exit=False)
165165

166166
from idlelib.idle_test.htest import run
167167
run(_calltip_window)

Lib/idlelib/editor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class EditorWindow(object):
5454
from idlelib.statusbar import MultiStatusBar
5555
from idlelib.autocomplete import AutoComplete
5656
from idlelib.autoexpand import AutoExpand
57-
from idlelib.calltips import CallTips
57+
from idlelib.calltip import Calltip
5858
from idlelib.codecontext import CodeContext
5959
from idlelib.paragraph import FormatParagraph
6060
from idlelib.parenmatch import ParenMatch
@@ -311,11 +311,11 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
311311
text.bind("<<check-module>>", scriptbinding.check_module_event)
312312
text.bind("<<run-module>>", scriptbinding.run_module_event)
313313
text.bind("<<do-rstrip>>", self.RstripExtension(self).do_rstrip)
314-
calltips = self.CallTips(self)
315-
text.bind("<<try-open-calltip>>", calltips.try_open_calltip_event)
316-
#refresh-calltips must come after paren-closed to work right
317-
text.bind("<<refresh-calltip>>", calltips.refresh_calltip_event)
318-
text.bind("<<force-open-calltip>>", calltips.force_open_calltip_event)
314+
ctip = self.Calltip(self)
315+
text.bind("<<try-open-calltip>>", ctip.try_open_calltip_event)
316+
#refresh-calltip must come after paren-closed to work right
317+
text.bind("<<refresh-calltip>>", ctip.refresh_calltip_event)
318+
text.bind("<<force-open-calltip>>", ctip.force_open_calltip_event)
319319
text.bind("<<zoom-height>>", self.ZoomHeight(self).zoom_height_event)
320320
text.bind("<<toggle-code-context>>",
321321
self.CodeContext(self).toggle_code_context_event)

Lib/idlelib/idle_test/test_calltips.py renamed to Lib/idlelib/idle_test/test_calltip.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
"Test calltips, coverage 60%"
1+
"Test calltip, coverage 60%"
22

3-
from idlelib import calltips
3+
from idlelib import calltip
44
import unittest
55
import textwrap
66
import types
77

8-
default_tip = calltips._default_callable_argspec
8+
default_tip = calltip._default_callable_argspec
99

1010

1111
# Test Class TC is used in multiple get_argspec test methods
@@ -36,7 +36,7 @@ def sm(b): 'doc'
3636

3737

3838
tc = TC()
39-
signature = calltips.get_argspec # 2.7 and 3.x use different functions
39+
signature = calltip.get_argspec # 2.7 and 3.x use different functions
4040

4141

4242
class Get_signatureTest(unittest.TestCase):
@@ -66,7 +66,7 @@ def gtest(obj, out):
6666
' See help(type) for accurate signature.')
6767
gtest(list.__init__,
6868
'(self, /, *args, **kwargs)'
69-
+ calltips._argument_positional + '\n' +
69+
+ calltip._argument_positional + '\n' +
7070
'Initialize self. See help(type(self)) for accurate signature.')
7171
append_doc = "L.append(object) -> None -- append object to end"
7272
gtest(list.append, append_doc)
@@ -100,7 +100,7 @@ def test_signature_wrap(self):
100100
def test_docline_truncation(self):
101101
def f(): pass
102102
f.__doc__ = 'a'*300
103-
self.assertEqual(signature(f), '()\n' + 'a' * (calltips._MAX_COLS-3) + '...')
103+
self.assertEqual(signature(f), '()\n' + 'a' * (calltip._MAX_COLS-3) + '...')
104104

105105
def test_multiline_docstring(self):
106106
# Test fewer lines than max.
@@ -119,7 +119,7 @@ def test_multiline_docstring(self):
119119
# Test more than max lines
120120
def f(): pass
121121
f.__doc__ = 'a\n' * 15
122-
self.assertEqual(signature(f), '()' + '\na' * calltips._MAX_LINES)
122+
self.assertEqual(signature(f), '()' + '\na' * calltip._MAX_LINES)
123123

124124
def test_functions(self):
125125
def t1(): 'doc'
@@ -166,15 +166,15 @@ def m2(**kwargs): pass
166166
class Test:
167167
def __call__(*, a): pass
168168

169-
mtip = calltips._invalid_method
169+
mtip = calltip._invalid_method
170170
self.assertEqual(signature(C().m2), mtip)
171171
self.assertEqual(signature(Test()), mtip)
172172

173173
def test_non_ascii_name(self):
174174
# test that re works to delete a first parameter name that
175175
# includes non-ascii chars, such as various forms of A.
176176
uni = "(A\u0391\u0410\u05d0\u0627\u0905\u1e00\u3042, a)"
177-
assert calltips._first_param.sub('', uni) == '(a)'
177+
assert calltip._first_param.sub('', uni) == '(a)'
178178

179179
def test_no_docstring(self):
180180
def nd(s):
@@ -207,9 +207,9 @@ def test_non_callables(self):
207207

208208
class Get_entityTest(unittest.TestCase):
209209
def test_bad_entity(self):
210-
self.assertIsNone(calltips.get_entity('1/0'))
210+
self.assertIsNone(calltip.get_entity('1/0'))
211211
def test_good_entity(self):
212-
self.assertIs(calltips.get_entity('int'), int)
212+
self.assertIs(calltip.get_entity('int'), int)
213213

214214

215215
if __name__ == '__main__':

Lib/idlelib/idle_test/test_calltip_w.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def setUpClass(cls):
1414
cls.root = Tk()
1515
cls.root.withdraw()
1616
cls.text = Text(cls.root)
17-
cls.calltip = calltip_w.CallTip(cls.text)
17+
cls.calltip = calltip_w.Calltip(cls.text)
1818

1919
@classmethod
2020
def tearDownClass(cls):

Lib/idlelib/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import tkinter # Tcl, deletions, messagebox if startup fails
1212

1313
from idlelib import autocomplete # AutoComplete, fetch_encodings
14-
from idlelib import calltips # CallTips
14+
from idlelib import calltip # Calltip
1515
from idlelib import debugger_r # start_debugger
1616
from idlelib import debugobj_r # remote_object_tree_item
1717
from idlelib import iomenu # encoding
@@ -462,7 +462,7 @@ class Executive(object):
462462
def __init__(self, rpchandler):
463463
self.rpchandler = rpchandler
464464
self.locals = __main__.__dict__
465-
self.calltip = calltips.CallTips()
465+
self.calltip = calltip.Calltip()
466466
self.autocomplete = autocomplete.AutoComplete()
467467

468468
def runcode(self, code):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
For consistency and appearance, rename an IDLE module and class. Module
2+
idlelib.calltips is now calltip. Class idlelib.calltip_w.CallTip is now
3+
Calltip.

0 commit comments

Comments
 (0)