@@ -679,11 +679,17 @@ def getargspec(func):
679679 try :
680680 if inspect .isclass (f ):
681681 self .current_func = f
682- argspec = inspect .getargspec (f .__init__ )
682+ if py3 :
683+ argspec = inspect .getfullargspec (f .__init__ )
684+ else :
685+ argspec = inspect .getargspec (f .__init__ )
683686 self .current_func = f .__init__
684687 is_bound_method = True
685688 else :
686- argspec = inspect .getargspec (f )
689+ if py3 :
690+ argspec = inspect .getfullargspec (f )
691+ else :
692+ argspec = inspect .getargspec (f )
687693 self .current_func = f
688694 argspec = list (argspec )
689695 fixlongargs (f , argspec )
@@ -830,6 +836,9 @@ def _complete(self, tab=False):
830836 if not e and self .argspec :
831837 matches .extend (name + '=' for name in self .argspec [1 ][0 ]
832838 if name .startswith (cw ))
839+ if py3 :
840+ matches .extend (name + '=' for name in self .argspec [1 ][4 ]
841+ if name .startswith (cw ))
833842
834843 if e or not matches :
835844 self .matches = []
@@ -1030,6 +1039,9 @@ def mkargspec(self, topline, down):
10301039 _kwargs = topline [1 ][2 ]
10311040 is_bound_method = topline [2 ]
10321041 in_arg = topline [3 ]
1042+ if py3 :
1043+ kwonly = topline [1 ][4 ]
1044+ kwonly_defaults = topline [1 ][5 ] or dict ()
10331045 max_w = int (self .scr .getmaxyx ()[1 ] * 0.6 )
10341046 self .list_win .erase ()
10351047 self .list_win .resize (3 , max_w )
@@ -1086,8 +1098,25 @@ def mkargspec(self, topline, down):
10861098 self .list_win .addstr (', ' , get_colpair ('punctuation' ))
10871099 self .list_win .addstr ('*%s' % (_args , ), get_colpair ('token' ))
10881100
1101+ if py3 and kwonly :
1102+ if not _args :
1103+ if args :
1104+ self .list_win .addstr (', ' , get_colpair ('punctuation' ))
1105+ self .list_win .addstr ('*' , get_colpair ('punctuation' ))
1106+ marker = object ()
1107+ for arg in kwonly :
1108+ self .list_win .addstr (', ' , get_colpair ('punctuation' ))
1109+ color = get_colpair ('token' )
1110+ if arg == in_arg :
1111+ color |= curses .A_BOLD
1112+ self .list_win .addstr (arg , color )
1113+ default = kwonly_defaults .get (arg , marker )
1114+ if default is not marker :
1115+ self .list_win .addstr ('=' , get_colpair ('punctuation' ))
1116+ self .list_win .addstr (repr (default ), get_colpair ('token' ))
1117+
10891118 if _kwargs :
1090- if args or _args :
1119+ if args or _args or ( py3 and kwonly ) :
10911120 self .list_win .addstr (', ' , get_colpair ('punctuation' ))
10921121 self .list_win .addstr ('**%s' % (_kwargs , ), get_colpair ('token' ))
10931122 self .list_win .addstr (')' , get_colpair ('punctuation' ))
0 commit comments