gh-73536: Add support for multi-signatures by serhiy-storchaka · Pull Request #117671 · python/cpython · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Lib/dataclasses.py
17 changes: 11 additions & 6 deletions Lib/idlelib/calltip.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,25 @@ def get_argspec(ob):

# Initialize argspec and wrap it to get lines.
try:
argspec = str(inspect.signature(fob))
signatures = inspect.signatures(fob)
except Exception as err:
msg = str(err)
if msg.startswith(_invalid_method):
return _invalid_method
else:
argspec = ''
signatures = []

if isinstance(fob, type) and argspec == '()':
lines = []
for sig in signatures:
line = str(sig)
if len(line) > _MAX_COLS:
lines.extend(textwrap.wrap(line, _MAX_COLS, subsequent_indent=_INDENT))
else:
lines.append(line)
if isinstance(fob, type) and lines == ['()']:
# If fob has no argument, use default callable argspec.
argspec = _default_callable_argspec
lines = [_default_callable_argspec]

lines = (textwrap.wrap(argspec, _MAX_COLS, subsequent_indent=_INDENT)
if len(argspec) > _MAX_COLS else [argspec] if argspec else [])

# Augment lines from docstring, if any, and join to get argspec.
doc = inspect.getdoc(ob)
Expand Down
32 changes: 32 additions & 0 deletions Lib/idlelib/idle_test/test_calltip.py
Loading
Loading