bpo-35763: Make IDLE calltip note about '/' less obtrusive (GH-13791)
Add it to the end of the first line if there is room. Tests were reworked.
diff --git a/Lib/idlelib/calltip.py b/Lib/idlelib/calltip.py
index b013a7f..a3dda26 100644
--- a/Lib/idlelib/calltip.py
+++ b/Lib/idlelib/calltip.py
@@ -118,7 +118,7 @@
_first_param = re.compile(r'(?<=\()\w*\,?\s*')
_default_callable_argspec = "See source or doc"
_invalid_method = "invalid method signature"
-_argument_positional = "\n['/' marks preceding arguments as positional-only]\n"
+_argument_positional = " # '/' marks preceding args as positional-only."
def get_argspec(ob):
'''Return a string describing the signature of a callable object, or ''.
@@ -144,11 +144,11 @@
if msg.startswith(_invalid_method):
return _invalid_method
- if '/' in argspec:
- """Using AC's positional argument should add the explain"""
+ if '/' in argspec and len(argspec) < _MAX_COLS - len(_argument_positional):
+ # Add explanation TODO remove after 3.7, before 3.9.
argspec += _argument_positional
if isinstance(fob, type) and argspec == '()':
- """fob with no argument, use default callable argspec"""
+ # If fob has no argument, use default callable argspec.
argspec = _default_callable_argspec
lines = (textwrap.wrap(argspec, _MAX_COLS, subsequent_indent=_INDENT)