mirror of
https://github.com/python/cpython.git
synced 2026-04-28 23:00:40 +00:00
[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 06e2029dfa)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
parent
90209a172c
commit
e97a685185
7 changed files with 33 additions and 30 deletions
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
@ -66,7 +66,7 @@ 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 = "L.append(object) -> None -- append object to end"
|
||||
gtest(list.append, append_doc)
|
||||
|
|
@ -100,7 +100,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.
|
||||
|
|
@ -119,7 +119,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'
|
||||
|
|
@ -166,7 +166,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)
|
||||
|
||||
|
|
@ -174,7 +174,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):
|
||||
|
|
@ -207,9 +207,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__':
|
||||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue