Skip to content

Commit 86a9cce

Browse files
committed
argspec replaced with namedtuple FuncProps, in_arg removed from original argspec and made into class var
1 parent ab3ed09 commit 86a9cce

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

bpython/repl.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ def __init__(self, interp, config):
359359
self.history = []
360360
self.evaluating = False
361361
self.matches_iter = MatchesIterator()
362-
self.argspec = None
362+
self.funcprops = None
363+
self.arg_pos = None
363364
self.current_func = None
364365
self.highlighted_paren = None
365366
self._C = {}
@@ -468,8 +469,8 @@ def get_object(self, name):
468469

469470
def get_args(self):
470471
"""Check if an unclosed parenthesis exists, then attempt to get the
471-
argspec() for it. On success, update self.argspec and return True,
472-
otherwise set self.argspec to None and return False"""
472+
argspec() for it. On success, update self.funcprops,self.arg_pos and return True,
473+
otherwise set self.funcprops to None and return False"""
473474

474475
self.current_func = None
475476

@@ -532,11 +533,11 @@ def get_args(self):
532533
except AttributeError:
533534
return None
534535
self.current_func = f
535-
536-
self.argspec = inspection.getargspec(func, f)
537-
if self.argspec:
538-
self.argspec.append(arg_number)
536+
self.funcprops = inspection.getfuncprops(func, f)
537+
if self.funcprops:
538+
self.arg_pos = arg_number
539539
return True
540+
self.arg_pos = None
540541
return False
541542

542543
def get_source_of_current_name(self):
@@ -567,7 +568,7 @@ def get_source_of_current_name(self):
567568
def set_docstring(self):
568569
self.docstring = None
569570
if not self.get_args():
570-
self.argspec = None
571+
self.funcprops = None
571572
elif self.current_func is not None:
572573
try:
573574
self.docstring = pydoc.getdoc(self.current_func)
@@ -609,7 +610,7 @@ def complete(self, tab=False):
609610
cursor_offset=self.cursor_offset,
610611
line=self.current_line,
611612
locals_=self.interp.locals,
612-
argspec=self.argspec,
613+
argspec=self.funcprops,
613614
current_block='\n'.join(self.buffer + [self.current_line]),
614615
complete_magic_methods=self.config.complete_magic_methods,
615616
history=self.history)
@@ -618,7 +619,7 @@ def complete(self, tab=False):
618619

619620
if len(matches) == 0:
620621
self.matches_iter.clear()
621-
return bool(self.argspec)
622+
return bool(self.funcprops)
622623

623624
self.matches_iter.update(self.cursor_offset,
624625
self.current_line, matches, completer)

0 commit comments

Comments
 (0)