Commit 06e2029d authored by Terry Jan Reedy's avatar Terry Jan Reedy Committed by GitHub

bpo-33907: Rename an IDLE module and class. (GH-7807)

Improve consistency and appearance. Module idlelib.calltips is now calltip.
Class idlelib.calltip_w.CallTip is now Calltip.
parent 4d92158f
...@@ -15,7 +15,7 @@ from idlelib.hyperparser import HyperParser ...@@ -15,7 +15,7 @@ from idlelib.hyperparser import HyperParser
import __main__ import __main__
class CallTips: class Calltip:
def __init__(self, editwin=None): def __init__(self, editwin=None):
if editwin is None: # subprocess and test if editwin is None: # subprocess and test
...@@ -31,7 +31,7 @@ class CallTips: ...@@ -31,7 +31,7 @@ class CallTips:
def _make_tk_calltip_window(self): def _make_tk_calltip_window(self):
# See __init__ for usage # See __init__ for usage
return calltip_w.CallTip(self.text) return calltip_w.Calltip(self.text)
def _remove_calltip_window(self, event=None): def _remove_calltip_window(self, event=None):
if self.active_calltip: if self.active_calltip:
...@@ -44,7 +44,7 @@ class CallTips: ...@@ -44,7 +44,7 @@ class CallTips:
return "break" return "break"
def try_open_calltip_event(self, event): def try_open_calltip_event(self, event):
"""Happens when it would be nice to open a CallTip, but not really """Happens when it would be nice to open a Calltip, but not really
necessary, for example after an opening bracket, so function calls necessary, for example after an opening bracket, so function calls
won't be made. won't be made.
""" """
...@@ -175,4 +175,4 @@ def get_argspec(ob): ...@@ -175,4 +175,4 @@ def get_argspec(ob):
if __name__ == '__main__': if __name__ == '__main__':
from unittest import main from unittest import main
main('idlelib.idle_test.test_calltips', verbosity=2) main('idlelib.idle_test.test_calltip', verbosity=2)
"""A CallTip window class for Tkinter/IDLE. """A Calltip window class for Tkinter/IDLE.
After tooltip.py, which uses ideas gleaned from PySol After tooltip.py, which uses ideas gleaned from PySol
Used by the calltips IDLE extension. Used by calltip.
""" """
from tkinter import Toplevel, Label, LEFT, SOLID, TclError from tkinter import Toplevel, Label, LEFT, SOLID, TclError
...@@ -13,7 +13,7 @@ CHECKHIDE_TIME = 100 # milliseconds ...@@ -13,7 +13,7 @@ CHECKHIDE_TIME = 100 # milliseconds
MARK_RIGHT = "calltipwindowregion_right" MARK_RIGHT = "calltipwindowregion_right"
class CallTip: class Calltip:
def __init__(self, widget): def __init__(self, widget):
self.widget = widget self.widget = widget
...@@ -47,7 +47,7 @@ class CallTip: ...@@ -47,7 +47,7 @@ class CallTip:
def showtip(self, text, parenleft, parenright): def showtip(self, text, parenleft, parenright):
"""Show the calltip, bind events which will close it and reposition it. """Show the calltip, bind events which will close it and reposition it.
""" """
# Only called in CallTips, where lines are truncated # Only called in Calltip, where lines are truncated
self.text = text self.text = text
if self.tipwindow or not self.text: if self.tipwindow or not self.text:
return return
...@@ -147,7 +147,7 @@ def _calltip_window(parent): # htest # ...@@ -147,7 +147,7 @@ def _calltip_window(parent): # htest #
text.pack(side=LEFT, fill=BOTH, expand=1) text.pack(side=LEFT, fill=BOTH, expand=1)
text.insert("insert", "string.split") text.insert("insert", "string.split")
top.update() top.update()
calltip = CallTip(text) calltip = Calltip(text)
def calltip_show(event): def calltip_show(event):
calltip.showtip("(s=Hello world)", "insert", "end") calltip.showtip("(s=Hello world)", "insert", "end")
...@@ -161,7 +161,7 @@ def _calltip_window(parent): # htest # ...@@ -161,7 +161,7 @@ def _calltip_window(parent): # htest #
if __name__ == '__main__': if __name__ == '__main__':
from unittest import main from unittest import main
main('idlelib.idle_test.test_calltips', verbosity=2, exit=False) main('idlelib.idle_test.test_calltip_w', verbosity=2, exit=False)
from idlelib.idle_test.htest import run from idlelib.idle_test.htest import run
run(_calltip_window) run(_calltip_window)
...@@ -54,7 +54,7 @@ class EditorWindow(object): ...@@ -54,7 +54,7 @@ class EditorWindow(object):
from idlelib.statusbar import MultiStatusBar from idlelib.statusbar import MultiStatusBar
from idlelib.autocomplete import AutoComplete from idlelib.autocomplete import AutoComplete
from idlelib.autoexpand import AutoExpand from idlelib.autoexpand import AutoExpand
from idlelib.calltips import CallTips from idlelib.calltip import Calltip
from idlelib.codecontext import CodeContext from idlelib.codecontext import CodeContext
from idlelib.paragraph import FormatParagraph from idlelib.paragraph import FormatParagraph
from idlelib.parenmatch import ParenMatch from idlelib.parenmatch import ParenMatch
...@@ -311,11 +311,11 @@ class EditorWindow(object): ...@@ -311,11 +311,11 @@ class EditorWindow(object):
text.bind("<<check-module>>", scriptbinding.check_module_event) text.bind("<<check-module>>", scriptbinding.check_module_event)
text.bind("<<run-module>>", scriptbinding.run_module_event) text.bind("<<run-module>>", scriptbinding.run_module_event)
text.bind("<<do-rstrip>>", self.RstripExtension(self).do_rstrip) text.bind("<<do-rstrip>>", self.RstripExtension(self).do_rstrip)
calltips = self.CallTips(self) ctip = self.Calltip(self)
text.bind("<<try-open-calltip>>", calltips.try_open_calltip_event) text.bind("<<try-open-calltip>>", ctip.try_open_calltip_event)
#refresh-calltips must come after paren-closed to work right #refresh-calltip must come after paren-closed to work right
text.bind("<<refresh-calltip>>", calltips.refresh_calltip_event) text.bind("<<refresh-calltip>>", ctip.refresh_calltip_event)
text.bind("<<force-open-calltip>>", calltips.force_open_calltip_event) text.bind("<<force-open-calltip>>", ctip.force_open_calltip_event)
text.bind("<<zoom-height>>", self.ZoomHeight(self).zoom_height_event) text.bind("<<zoom-height>>", self.ZoomHeight(self).zoom_height_event)
text.bind("<<toggle-code-context>>", text.bind("<<toggle-code-context>>",
self.CodeContext(self).toggle_code_context_event) self.CodeContext(self).toggle_code_context_event)
......
"Test calltips, coverage 60%" "Test calltip, coverage 60%"
from idlelib import calltips from idlelib import calltip
import unittest import unittest
import textwrap import textwrap
import types import types
default_tip = calltips._default_callable_argspec default_tip = calltip._default_callable_argspec
# Test Class TC is used in multiple get_argspec test methods # Test Class TC is used in multiple get_argspec test methods
...@@ -36,7 +36,7 @@ class TC(): ...@@ -36,7 +36,7 @@ class TC():
tc = TC() tc = TC()
signature = calltips.get_argspec # 2.7 and 3.x use different functions signature = calltip.get_argspec # 2.7 and 3.x use different functions
class Get_signatureTest(unittest.TestCase): class Get_signatureTest(unittest.TestCase):
...@@ -59,7 +59,7 @@ class Get_signatureTest(unittest.TestCase): ...@@ -59,7 +59,7 @@ class Get_signatureTest(unittest.TestCase):
self.assertEqual(signature(obj), out) self.assertEqual(signature(obj), out)
if List.__doc__ is not None: if List.__doc__ is not None:
gtest(List, '(iterable=(), /)' + calltips._argument_positional gtest(List, '(iterable=(), /)' + calltip._argument_positional
+ '\n' + List.__doc__) + '\n' + List.__doc__)
gtest(list.__new__, gtest(list.__new__,
'(*args, **kwargs)\n' '(*args, **kwargs)\n'
...@@ -67,9 +67,9 @@ class Get_signatureTest(unittest.TestCase): ...@@ -67,9 +67,9 @@ class Get_signatureTest(unittest.TestCase):
'See help(type) for accurate signature.') 'See help(type) for accurate signature.')
gtest(list.__init__, gtest(list.__init__,
'(self, /, *args, **kwargs)' '(self, /, *args, **kwargs)'
+ calltips._argument_positional + '\n' + + calltip._argument_positional + '\n' +
'Initialize self. See help(type(self)) for accurate signature.') 'Initialize self. See help(type(self)) for accurate signature.')
append_doc = (calltips._argument_positional append_doc = (calltip._argument_positional
+ "\nAppend object to the end of the list.") + "\nAppend object to the end of the list.")
gtest(list.append, '(self, object, /)' + append_doc) gtest(list.append, '(self, object, /)' + append_doc)
gtest(List.append, '(self, object, /)' + append_doc) gtest(List.append, '(self, object, /)' + append_doc)
...@@ -102,7 +102,7 @@ non-overlapping occurrences o...''') ...@@ -102,7 +102,7 @@ non-overlapping occurrences o...''')
def test_docline_truncation(self): def test_docline_truncation(self):
def f(): pass def f(): pass
f.__doc__ = 'a'*300 f.__doc__ = 'a'*300
self.assertEqual(signature(f), '()\n' + 'a' * (calltips._MAX_COLS-3) + '...') self.assertEqual(signature(f), '()\n' + 'a' * (calltip._MAX_COLS-3) + '...')
def test_multiline_docstring(self): def test_multiline_docstring(self):
# Test fewer lines than max. # Test fewer lines than max.
...@@ -121,7 +121,7 @@ bytes() -> empty bytes object''') ...@@ -121,7 +121,7 @@ bytes() -> empty bytes object''')
# Test more than max lines # Test more than max lines
def f(): pass def f(): pass
f.__doc__ = 'a\n' * 15 f.__doc__ = 'a\n' * 15
self.assertEqual(signature(f), '()' + '\na' * calltips._MAX_LINES) self.assertEqual(signature(f), '()' + '\na' * calltip._MAX_LINES)
def test_functions(self): def test_functions(self):
def t1(): 'doc' def t1(): 'doc'
...@@ -168,7 +168,7 @@ bytes() -> empty bytes object''') ...@@ -168,7 +168,7 @@ bytes() -> empty bytes object''')
class Test: class Test:
def __call__(*, a): pass def __call__(*, a): pass
mtip = calltips._invalid_method mtip = calltip._invalid_method
self.assertEqual(signature(C().m2), mtip) self.assertEqual(signature(C().m2), mtip)
self.assertEqual(signature(Test()), mtip) self.assertEqual(signature(Test()), mtip)
...@@ -176,7 +176,7 @@ bytes() -> empty bytes object''') ...@@ -176,7 +176,7 @@ bytes() -> empty bytes object''')
# test that re works to delete a first parameter name that # test that re works to delete a first parameter name that
# includes non-ascii chars, such as various forms of A. # includes non-ascii chars, such as various forms of A.
uni = "(A\u0391\u0410\u05d0\u0627\u0905\u1e00\u3042, a)" uni = "(A\u0391\u0410\u05d0\u0627\u0905\u1e00\u3042, a)"
assert calltips._first_param.sub('', uni) == '(a)' assert calltip._first_param.sub('', uni) == '(a)'
def test_no_docstring(self): def test_no_docstring(self):
def nd(s): def nd(s):
...@@ -209,9 +209,9 @@ bytes() -> empty bytes object''') ...@@ -209,9 +209,9 @@ bytes() -> empty bytes object''')
class Get_entityTest(unittest.TestCase): class Get_entityTest(unittest.TestCase):
def test_bad_entity(self): def test_bad_entity(self):
self.assertIsNone(calltips.get_entity('1/0')) self.assertIsNone(calltip.get_entity('1/0'))
def test_good_entity(self): def test_good_entity(self):
self.assertIs(calltips.get_entity('int'), int) self.assertIs(calltip.get_entity('int'), int)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -14,7 +14,7 @@ class CallTipTest(unittest.TestCase): ...@@ -14,7 +14,7 @@ class CallTipTest(unittest.TestCase):
cls.root = Tk() cls.root = Tk()
cls.root.withdraw() cls.root.withdraw()
cls.text = Text(cls.root) cls.text = Text(cls.root)
cls.calltip = calltip_w.CallTip(cls.text) cls.calltip = calltip_w.Calltip(cls.text)
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
......
...@@ -11,7 +11,7 @@ import warnings ...@@ -11,7 +11,7 @@ import warnings
import tkinter # Tcl, deletions, messagebox if startup fails import tkinter # Tcl, deletions, messagebox if startup fails
from idlelib import autocomplete # AutoComplete, fetch_encodings from idlelib import autocomplete # AutoComplete, fetch_encodings
from idlelib import calltips # CallTips from idlelib import calltip # Calltip
from idlelib import debugger_r # start_debugger from idlelib import debugger_r # start_debugger
from idlelib import debugobj_r # remote_object_tree_item from idlelib import debugobj_r # remote_object_tree_item
from idlelib import iomenu # encoding from idlelib import iomenu # encoding
...@@ -462,7 +462,7 @@ class Executive(object): ...@@ -462,7 +462,7 @@ class Executive(object):
def __init__(self, rpchandler): def __init__(self, rpchandler):
self.rpchandler = rpchandler self.rpchandler = rpchandler
self.locals = __main__.__dict__ self.locals = __main__.__dict__
self.calltip = calltips.CallTips() self.calltip = calltip.Calltip()
self.autocomplete = autocomplete.AutoComplete() self.autocomplete = autocomplete.AutoComplete()
def runcode(self, code): def runcode(self, code):
......
For consistency and appearance, rename an IDLE module and class. Module
idlelib.calltips is now calltip. Class idlelib.calltip_w.CallTip is now
Calltip.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment