Skip to content

Commit 6586815

Browse files
committed
Argspec - Named tuple FuncProps related refactoring
1 parent 83abeb6 commit 6586815

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

bpython/cli.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ def complete(self, tab=False):
461461
list_win_visible = repl.Repl.complete(self, tab)
462462
if list_win_visible:
463463
try:
464-
self.show_list(self.matches_iter.matches, topline=self.argspec, formatter=self.matches_iter.completer.format)
464+
self.show_list(self.matches_iter.matches, self.arg_pos,
465+
topline=self.funcprops,
466+
formatter=self.matches_iter.completer.format)
465467
except curses.error:
466468
# XXX: This is a massive hack, it will go away when I get
467469
# cusswords into a good enough state that we can start
@@ -691,7 +693,7 @@ def lf(self):
691693
self.print_line(self.s, newline=True)
692694
self.echo("\n")
693695

694-
def mkargspec(self, topline, down):
696+
def mkargspec(self, topline, in_arg, down):
695697
"""This figures out what to do with the argspec and puts it nicely into
696698
the list window. It returns the number of lines used to display the
697699
argspec. It's also kind of messy due to it having to call so many
@@ -700,15 +702,13 @@ def mkargspec(self, topline, down):
700702

701703
r = 3
702704
fn = topline.func
703-
args = topline.arginfo.args
704-
kwargs = topline.arginfo.defaults
705-
_args = topline.arginfo.varargs
706-
_kwargs = topline.arginfo.varkwargs
705+
args = topline.argspec.args
706+
kwargs = topline.argspec.defaults
707+
_args = topline.argspec.varargs
708+
_kwargs = topline.argspec.varkwargs
707709
is_bound_method = topline.is_bound_method
708-
in_arg = topline.in_arg
709-
print "\n\nprinting topline",topline
710710
if py3:
711-
kwonly = topline.arginfo.kwonly
711+
kwonly = topline.argspec.kwonly
712712
kwonly_defaults = topline.kwonly_defaults or dict()
713713
max_w = int(self.scr.getmaxyx()[1] * 0.6)
714714
self.list_win.erase()
@@ -1254,7 +1254,7 @@ def write(self, s):
12541254
self.s_hist.append(s.rstrip())
12551255

12561256

1257-
def show_list(self, items, topline=None, formatter=None, current_item=None):
1257+
def show_list(self, items, arg_pos, topline=None, formatter=None, current_item=None):
12581258

12591259
shared = Struct()
12601260
shared.cols = 0
@@ -1276,7 +1276,7 @@ def show_list(self, items, topline=None, formatter=None, current_item=None):
12761276
current_item = formatter(current_item)
12771277

12781278
if topline:
1279-
height_offset = self.mkargspec(topline, down) + 1
1279+
height_offset = self.mkargspec(topline, arg_pos, down) + 1
12801280
else:
12811281
height_offset = 0
12821282

@@ -1455,7 +1455,8 @@ def tab(self, back=False):
14551455
current_match = back and self.matches_iter.previous() \
14561456
or next(self.matches_iter)
14571457
try:
1458-
self.show_list(self.matches_iter.matches, topline=self.funcprops,
1458+
self.show_list(self.matches_iter.matches, self.arg_pos,
1459+
topline=self.funcprops,
14591460
formatter=self.matches_iter.completer.format,
14601461
current_item=current_match)
14611462
except curses.error:

0 commit comments

Comments
 (0)