summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Arias <emmanuelarias30@gmail.com>2019-01-03 07:47:58 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2019-01-03 07:47:58 (GMT)
commitab54b9a130c88f708077c2ef6c4963b632c132b3 (patch)
tree7f57fa7d5bdd93e0774089123792cd92bc7ff083
parentaff0adabf3ace62073076f4ce875ff568f2d3180 (diff)
downloadcpython-ab54b9a130c88f708077c2ef6c4963b632c132b3.zip
cpython-ab54b9a130c88f708077c2ef6c4963b632c132b3.tar.gz
cpython-ab54b9a130c88f708077c2ef6c4963b632c132b3.tar.bz2
bpo-35641: IDLE - format calltip properly when no docstring (GH-11415)
-rw-r--r--Lib/idlelib/calltip.py2
-rw-r--r--Lib/idlelib/idle_test/test_calltip.py29
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS.d/next/Library/2019-01-02-22-15-01.bpo-35641.QEaANl.rst1
4 files changed, 32 insertions, 1 deletions
diff --git a/Lib/idlelib/calltip.py b/Lib/idlelib/calltip.py
index 758569a..2a9a131 100644
--- a/Lib/idlelib/calltip.py
+++ b/Lib/idlelib/calltip.py
@@ -167,7 +167,7 @@ def get_argspec(ob):
if len(line) > _MAX_COLS:
line = line[: _MAX_COLS - 3] + '...'
lines.append(line)
- argspec = '\n'.join(lines)
+ argspec = '\n'.join(lines)
if not argspec:
argspec = _default_callable_argspec
return argspec
diff --git a/Lib/idlelib/idle_test/test_calltip.py b/Lib/idlelib/idle_test/test_calltip.py
index 0698d4f..833351b 100644
--- a/Lib/idlelib/idle_test/test_calltip.py
+++ b/Lib/idlelib/idle_test/test_calltip.py
@@ -99,6 +99,35 @@ non-overlapping occurrences o...''')
drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None,
placeholder=' [...]')''')
+ def test_properly_formated(self):
+ def foo(s='a'*100):
+ pass
+
+ def bar(s='a'*100):
+ """Hello Guido"""
+ pass
+
+ def baz(s='a'*100, z='b'*100):
+ pass
+
+ indent = calltip._INDENT
+
+ str_foo = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\
+ "aaaaaaaaaa')"
+ str_bar = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\
+ "aaaaaaaaaa')\nHello Guido"
+ str_baz = "(s='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + indent + "aaaaaaaaa"\
+ "aaaaaaaaaa', z='bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"\
+ "bbbbbbbbbbbbbbbbb\n" + indent + "bbbbbbbbbbbbbbbbbbbbbb"\
+ "bbbbbbbbbbbbbbbbbbbbbb')"
+
+ self.assertEqual(calltip.get_argspec(foo), str_foo)
+ self.assertEqual(calltip.get_argspec(bar), str_bar)
+ self.assertEqual(calltip.get_argspec(baz), str_baz)
+
def test_docline_truncation(self):
def f(): pass
f.__doc__ = 'a'*300
diff --git a/Misc/ACKS b/Misc/ACKS
index 63df5df..49b2815 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -60,6 +60,7 @@ Heidi Annexstad
Ramchandra Apte
Éric Araujo
Alexandru Ardelean
+Emmanuel Arias
Alicia Arlen
Jeffrey Armstrong
Jason Asbahr
diff --git a/Misc/NEWS.d/next/Library/2019-01-02-22-15-01.bpo-35641.QEaANl.rst b/Misc/NEWS.d/next/Library/2019-01-02-22-15-01.bpo-35641.QEaANl.rst
new file mode 100644
index 0000000..5abba69
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-01-02-22-15-01.bpo-35641.QEaANl.rst
@@ -0,0 +1 @@
+Proper format `calltip` when the function has no docstring.