[Python-checkins] bpo-33907: Rename an IDLE module and class. (GH-7807)

Miss Islington (bot) webhook-mailer at python.org
Tue Jun 19 23:27:40 EDT 2018


https://github.com/python/cpython/commit/b89a376b3b9bdc3b6f1b7d05ff64babcbfd93cc2
commit: b89a376b3b9bdc3b6f1b7d05ff64babcbfd93cc2
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-06-19T20:27:37-07:00
summary:

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.
(cherry picked from commit 06e2029dfa500a42e3565ed7ba8573412f153d1c)

Co-authored-by: Terry Jan Reedy <tjreedy at udel.edu>

files:
A Lib/idlelib/calltip.py
A Lib/idlelib/idle_test/test_calltip.py
A Misc/NEWS.d/next/IDLE/2018-06-19-22-21-27.bpo-33907.z-_B3N.rst
D Lib/idlelib/calltips.py
D Lib/idlelib/idle_test/test_calltips.py
M Lib/idlelib/calltip_w.py
M Lib/idlelib/editor.py
M Lib/idlelib/idle_test/test_calltip_w.py
M Lib/idlelib/run.py

diff --git a/Lib/idlelib/calltips.py b/Lib/idlelib/calltip.py
similarity index 97%
rename from Lib/idlelib/calltips.py
rename to Lib/idlelib/calltip.py
index ec8f6169895b..1ff0deb96844 100644
--- a/Lib/idlelib/calltips.py
+++ b/Lib/idlelib/calltip.py
@@ -15,7 +15,7 @@
 import __main__
 
 
-class CallTips:
+class Calltip:
 
     def __init__(self, editwin=None):
         if editwin is None:  # subprocess and test
@@ -31,7 +31,7 @@ def close(self):
 
     def _make_tk_calltip_window(self):
         # See __init__ for usage
-        return calltip_w.CallTip(self.text)
+        return calltip_w.Calltip(self.text)
 
     def _remove_calltip_window(self, event=None):
         if self.active_calltip:
@@ -44,7 +44,7 @@ def force_open_calltip_event(self, event):
         return "break"
 
     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
         won't be made.
         """
@@ -175,4 +175,4 @@ def get_argspec(ob):
 
 if __name__ == '__main__':
     from unittest import main
-    main('idlelib.idle_test.test_calltips', verbosity=2)
+    main('idlelib.idle_test.test_calltip', verbosity=2)
diff --git a/Lib/idlelib/calltip_w.py b/Lib/idlelib/calltip_w.py
index 122b73abef68..b75e4c27db34 100644
--- a/Lib/idlelib/calltip_w.py
+++ b/Lib/idlelib/calltip_w.py
@@ -1,7 +1,7 @@
-"""A CallTip window class for Tkinter/IDLE.
+"""A Calltip window class for Tkinter/IDLE.
 
 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
 
@@ -13,7 +13,7 @@
 
 MARK_RIGHT = "calltipwindowregion_right"
 
-class CallTip:
+class Calltip:
 
     def __init__(self, widget):
         self.widget = widget
@@ -47,7 +47,7 @@ def position_window(self):
     def showtip(self, text, parenleft, parenright):
         """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
         if self.tipwindow or not self.text:
             return
@@ -147,7 +147,7 @@ def _calltip_window(parent):  # htest #
     text.pack(side=LEFT, fill=BOTH, expand=1)
     text.insert("insert", "string.split")
     top.update()
-    calltip = CallTip(text)
+    calltip = Calltip(text)
 
     def calltip_show(event):
         calltip.showtip("(s=Hello world)", "insert", "end")
@@ -161,7 +161,7 @@ def calltip_hide(event):
 
 if __name__ == '__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
     run(_calltip_window)
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index 0095bd03bb7b..f5a091860ec6 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -54,7 +54,7 @@ class EditorWindow(object):
     from idlelib.statusbar import MultiStatusBar
     from idlelib.autocomplete import AutoComplete
     from idlelib.autoexpand import AutoExpand
-    from idlelib.calltips import CallTips
+    from idlelib.calltip import Calltip
     from idlelib.codecontext import CodeContext
     from idlelib.paragraph import FormatParagraph
     from idlelib.parenmatch import ParenMatch
@@ -311,11 +311,11 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
         text.bind("<<check-module>>", scriptbinding.check_module_event)
         text.bind("<<run-module>>", scriptbinding.run_module_event)
         text.bind("<<do-rstrip>>", self.RstripExtension(self).do_rstrip)
-        calltips = self.CallTips(self)
-        text.bind("<<try-open-calltip>>", calltips.try_open_calltip_event)
-        #refresh-calltips must come after paren-closed to work right
-        text.bind("<<refresh-calltip>>", calltips.refresh_calltip_event)
-        text.bind("<<force-open-calltip>>", calltips.force_open_calltip_event)
+        ctip = self.Calltip(self)
+        text.bind("<<try-open-calltip>>", ctip.try_open_calltip_event)
+        #refresh-calltip must come after paren-closed to work right
+        text.bind("<<refresh-calltip>>", ctip.refresh_calltip_event)
+        text.bind("<<force-open-calltip>>", ctip.force_open_calltip_event)
         text.bind("<<zoom-height>>", self.ZoomHeight(self).zoom_height_event)
         text.bind("<<toggle-code-context>>",
                   self.CodeContext(self).toggle_code_context_event)
diff --git a/Lib/idlelib/idle_test/test_calltips.py b/Lib/idlelib/idle_test/test_calltip.py
similarity index 90%
rename from Lib/idlelib/idle_test/test_calltips.py
rename to Lib/idlelib/idle_test/test_calltip.py
index 2cf0e188dae6..0698d4f8b99e 100644
--- a/Lib/idlelib/idle_test/test_calltips.py
+++ b/Lib/idlelib/idle_test/test_calltip.py
@@ -1,11 +1,11 @@
-"Test calltips, coverage 60%"
+"Test calltip, coverage 60%"
 
-from idlelib import calltips
+from idlelib import calltip
 import unittest
 import textwrap
 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
@@ -36,7 +36,7 @@ def sm(b): 'doc'
 
 
 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):
@@ -59,7 +59,7 @@ def gtest(obj, out):
             self.assertEqual(signature(obj), out)
 
         if List.__doc__ is not None:
-            gtest(List, '(iterable=(), /)' + calltips._argument_positional
+            gtest(List, '(iterable=(), /)' + calltip._argument_positional
                   + '\n' + List.__doc__)
         gtest(list.__new__,
               '(*args, **kwargs)\n'
@@ -67,9 +67,9 @@ def gtest(obj, out):
               'See help(type) for accurate signature.')
         gtest(list.__init__,
               '(self, /, *args, **kwargs)'
-              + calltips._argument_positional + '\n' +
+              + calltip._argument_positional + '\n' +
               '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.")
         gtest(list.append, '(self, object, /)' + append_doc)
         gtest(List.append, '(self, object, /)' + append_doc)
@@ -102,7 +102,7 @@ def test_signature_wrap(self):
     def test_docline_truncation(self):
         def f(): pass
         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):
         # Test fewer lines than max.
@@ -121,7 +121,7 @@ def test_multiline_docstring(self):
         # Test more than max lines
         def f(): pass
         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 t1(): 'doc'
@@ -168,7 +168,7 @@ def m2(**kwargs): pass
         class Test:
             def __call__(*, a): pass
 
-        mtip = calltips._invalid_method
+        mtip = calltip._invalid_method
         self.assertEqual(signature(C().m2), mtip)
         self.assertEqual(signature(Test()), mtip)
 
@@ -176,7 +176,7 @@ def test_non_ascii_name(self):
         # test that re works to delete a first parameter name that
         # includes non-ascii chars, such as various forms of 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 nd(s):
@@ -209,9 +209,9 @@ def test_non_callables(self):
 
 class Get_entityTest(unittest.TestCase):
     def test_bad_entity(self):
-        self.assertIsNone(calltips.get_entity('1/0'))
+        self.assertIsNone(calltip.get_entity('1/0'))
     def test_good_entity(self):
-        self.assertIs(calltips.get_entity('int'), int)
+        self.assertIs(calltip.get_entity('int'), int)
 
 
 if __name__ == '__main__':
diff --git a/Lib/idlelib/idle_test/test_calltip_w.py b/Lib/idlelib/idle_test/test_calltip_w.py
index 03f1e9a68a25..fc1f11140035 100644
--- a/Lib/idlelib/idle_test/test_calltip_w.py
+++ b/Lib/idlelib/idle_test/test_calltip_w.py
@@ -14,7 +14,7 @@ def setUpClass(cls):
         cls.root = Tk()
         cls.root.withdraw()
         cls.text = Text(cls.root)
-        cls.calltip = calltip_w.CallTip(cls.text)
+        cls.calltip = calltip_w.Calltip(cls.text)
 
     @classmethod
     def tearDownClass(cls):
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 176fe3db743b..6fa373f2584c 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -11,7 +11,7 @@
 import tkinter  # Tcl, deletions, messagebox if startup fails
 
 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 debugobj_r  # remote_object_tree_item
 from idlelib import iomenu  # encoding
@@ -462,7 +462,7 @@ class Executive(object):
     def __init__(self, rpchandler):
         self.rpchandler = rpchandler
         self.locals = __main__.__dict__
-        self.calltip = calltips.CallTips()
+        self.calltip = calltip.Calltip()
         self.autocomplete = autocomplete.AutoComplete()
 
     def runcode(self, code):
diff --git a/Misc/NEWS.d/next/IDLE/2018-06-19-22-21-27.bpo-33907.z-_B3N.rst b/Misc/NEWS.d/next/IDLE/2018-06-19-22-21-27.bpo-33907.z-_B3N.rst
new file mode 100644
index 000000000000..9c5a070e88ed
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2018-06-19-22-21-27.bpo-33907.z-_B3N.rst
@@ -0,0 +1,3 @@
+For consistency and appearance, rename an IDLE module and class. Module
+idlelib.calltips is now calltip.  Class idlelib.calltip_w.CallTip is now
+Calltip.



More information about the Python-checkins mailing list