@@ -72,19 +72,17 @@ def matches_lines(rows, columns, matches, current, config, format):
72
72
return matches_lines
73
73
74
74
75
- def formatted_argspec (argspec , columns , config ):
75
+ def formatted_argspec (funcprops , arg_pos , columns , config ):
76
76
# Pretty directly taken from bpython.cli
77
- is_bound_method = argspec [2 ]
78
- func = argspec [0 ]
79
- args = argspec [1 ][0 ]
80
- kwargs = argspec [1 ][3 ]
81
- _args = argspec [1 ][1 ] # *args
82
- _kwargs = argspec [1 ][2 ] # **kwargs
83
- is_bound_method = argspec [2 ]
84
- in_arg = argspec [3 ]
77
+ func = funcprops .func
78
+ args = funcprops .argspec .args
79
+ kwargs = funcprops .argspec .defaults
80
+ _args = funcprops .argspec .varargs
81
+ _kwargs = funcprops .argspec .varkwargs
82
+ is_bound_method = funcprops .is_bound_method
85
83
if py3 :
86
- kwonly = argspec [ 1 ][ 4 ]
87
- kwonly_defaults = argspec [ 1 ][ 5 ] or dict ()
84
+ kwonly = funcprops . argspec . kwonly
85
+ kwonly_defaults = funcprops . argspec . kwonly_defaults or dict ()
88
86
89
87
arg_color = func_for_letter (config .color_scheme ['name' ])
90
88
func_color = func_for_letter (config .color_scheme ['name' ].swapcase ())
@@ -95,16 +93,16 @@ def formatted_argspec(argspec, columns, config):
95
93
96
94
s = func_color (func ) + arg_color (': (' )
97
95
98
- if is_bound_method and isinstance (in_arg , int ):
96
+ if is_bound_method and isinstance (arg_pos , int ):
99
97
# TODO what values could this have?
100
- in_arg += 1
98
+ arg_pos += 1
101
99
102
100
for i , arg in enumerate (args ):
103
101
kw = None
104
102
if kwargs and i >= len (args ) - len (kwargs ):
105
103
kw = str (kwargs [i - (len (args ) - len (kwargs ))])
106
- color = token_color if in_arg in (i , arg ) else arg_color
107
- if i == in_arg or arg == in_arg :
104
+ color = token_color if arg_pos in (i , arg ) else arg_color
105
+ if i == arg_pos or arg == arg_pos :
108
106
color = bolds [color ]
109
107
110
108
if not py3 :
@@ -135,7 +133,7 @@ def formatted_argspec(argspec, columns, config):
135
133
for arg in kwonly :
136
134
s += punctuation_color (', ' )
137
135
color = token_color
138
- if in_arg :
136
+ if arg_pos :
139
137
color = bolds [color ]
140
138
s += color (arg )
141
139
default = kwonly_defaults .get (arg , marker )
@@ -159,13 +157,13 @@ def formatted_docstring(docstring, columns, config):
159
157
for line in docstring .split ('\n ' )), [])
160
158
161
159
162
- def paint_infobox (rows , columns , matches , argspec , match , docstring , config ,
160
+ def paint_infobox (rows , columns , matches , funcprops , arg_pos , match , docstring , config ,
163
161
format ):
164
- """Returns painted completions, argspec , match, docstring etc."""
162
+ """Returns painted completions, funcprops , match, docstring etc."""
165
163
if not (rows and columns ):
166
164
return fsarray (0 , 0 )
167
165
width = columns - 4
168
- lines = ((formatted_argspec (argspec , width , config ) if argspec else []) +
166
+ lines = ((formatted_argspec (funcprops , arg_pos , width , config ) if funcprops else []) +
169
167
(matches_lines (rows , width , matches , match , config , format )
170
168
if matches else []) +
171
169
(formatted_docstring (docstring , width , config )
0 commit comments