1
0
forked from VimPlug/jedi

Also don't complete keywords if kwargs only are allowed, see #1541

This commit is contained in:
Dave Halter
2020-04-17 23:51:40 +02:00
parent f07dee3564
commit 0850b86456
2 changed files with 9 additions and 8 deletions

View File

@@ -258,12 +258,7 @@ class Completion:
completion_names = [] completion_names = []
current_line = self._code_lines[self._position[0] - 1][:self._position[1]] current_line = self._code_lines[self._position[0] - 1][:self._position[1]]
completion_names += self._complete_keywords( kwargs_only = False
allowed_transitions,
only_values=not (not current_line or current_line[-1] in ' \t.;'
and current_line[-3:] != '...')
)
if any(t in allowed_transitions for t in (PythonTokenTypes.NAME, if any(t in allowed_transitions for t in (PythonTokenTypes.NAME,
PythonTokenTypes.INDENT)): PythonTokenTypes.INDENT)):
# This means that we actually have to do type inference. # This means that we actually have to do type inference.
@@ -299,7 +294,6 @@ class Completion:
# with `(`. Other trailers could start with `.` or `[`. # with `(`. Other trailers could start with `.` or `[`.
# 3. Decorators are very primitive and have an optional `(` with # 3. Decorators are very primitive and have an optional `(` with
# optional arglist in them. # optional arglist in them.
kwargs_only = False
if nodes[-1] in ['(', ','] \ if nodes[-1] in ['(', ','] \
and nonterminals[-1] in ('trailer', 'arglist', 'decorator'): and nonterminals[-1] in ('trailer', 'arglist', 'decorator'):
signatures = self._signatures_callback(*self._position) signatures = self._signatures_callback(*self._position)
@@ -320,6 +314,13 @@ class Completion:
completion_names += self._complete_global_scope() completion_names += self._complete_global_scope()
completion_names += self._complete_inherited(is_function=False) completion_names += self._complete_inherited(is_function=False)
if not kwargs_only:
completion_names += self._complete_keywords(
allowed_transitions,
only_values=not (not current_line or current_line[-1] in ' \t.;'
and current_line[-3:] != '...')
)
return cached_name, completion_names return cached_name, completion_names
def _is_parameter_completion(self): def _is_parameter_completion(self):

View File

@@ -22,7 +22,7 @@ def test_empty_init(Script):
code = dedent('''\ code = dedent('''\
class X(object): pass class X(object): pass
X(''') X(''')
assert Script(code).complete() assert not Script(code).complete()
def test_in_empty_space(Script): def test_in_empty_space(Script):