@@ -604,7 +604,12 @@ def matches(
604604 return matches if matches else None
605605
606606 def locate (self , cursor_offset : int , line : str ) -> Optional [LinePart ]:
607- return lineparts .current_word (cursor_offset , line )
607+ r = lineparts .current_word (cursor_offset , line )
608+ if r and r .word [- 1 ] == "(" :
609+ # if the word ends with a (, it's the parent word with an empty
610+ # param. Return an empty word
611+ return lineparts .LinePart (r .stop , r .stop , "" )
612+ return r
608613
609614
610615class ExpressionAttributeCompletion (AttrCompletion ):
@@ -742,6 +747,16 @@ def get_completer(
742747 double underscore methods like __len__ in method signatures
743748 """
744749
750+ def _cmpl_sort (x : str ) -> Tuple [bool , ...]:
751+ """
752+ Function used to sort the matches.
753+ """
754+ # put parameters above everything in completion
755+ return (
756+ x [- 1 ] != "=" ,
757+ x ,
758+ )
759+
745760 for completer in completers :
746761 try :
747762 matches = completer .matches (
@@ -760,7 +775,9 @@ def get_completer(
760775 )
761776 continue
762777 if matches is not None :
763- return sorted (matches ), (completer if matches else None )
778+ return sorted (matches , key = _cmpl_sort ), (
779+ completer if matches else None
780+ )
764781
765782 return [], None
766783
0 commit comments