forked from VimPlug/jedi
Fix remaining issues with dict completions
This commit is contained in:
@@ -101,7 +101,10 @@ class Completion:
|
|||||||
self._fuzzy = fuzzy
|
self._fuzzy = fuzzy
|
||||||
|
|
||||||
def complete(self, fuzzy):
|
def complete(self, fuzzy):
|
||||||
leaf = self._module_node.get_leaf_for_position(self._original_position, include_prefixes=True)
|
leaf = self._module_node.get_leaf_for_position(
|
||||||
|
self._original_position,
|
||||||
|
include_prefixes=True
|
||||||
|
)
|
||||||
string, start_leaf, quote = _extract_string_while_in_string(leaf, self._original_position)
|
string, start_leaf, quote = _extract_string_while_in_string(leaf, self._original_position)
|
||||||
|
|
||||||
prefixed_completions = complete_dict(
|
prefixed_completions = complete_dict(
|
||||||
|
|||||||
@@ -355,7 +355,22 @@ class TreeInstance(_BaseTreeInstance):
|
|||||||
return self._get_annotated_class_object() or self.class_value
|
return self._get_annotated_class_object() or self.class_value
|
||||||
|
|
||||||
def get_key_values(self):
|
def get_key_values(self):
|
||||||
return NO_VALUES
|
values = NO_VALUES
|
||||||
|
if self.array_type == 'dict':
|
||||||
|
for i, (key, instance) in enumerate(self._arguments.unpack()):
|
||||||
|
if key is None and i == 0:
|
||||||
|
values |= ValueSet.from_sets(
|
||||||
|
v.get_key_values()
|
||||||
|
for v in instance.infer()
|
||||||
|
if v.array_type == 'dict'
|
||||||
|
)
|
||||||
|
if key:
|
||||||
|
values |= ValueSet([compiled.create_simple_object(
|
||||||
|
self.inference_state,
|
||||||
|
key,
|
||||||
|
)])
|
||||||
|
|
||||||
|
return values
|
||||||
|
|
||||||
def py__simple_getitem__(self, index):
|
def py__simple_getitem__(self, index):
|
||||||
if self.array_type == 'dict':
|
if self.array_type == 'dict':
|
||||||
|
|||||||
@@ -308,8 +308,16 @@ _dict_keys_completion_tests = [
|
|||||||
('mixed[', 6, [r"'a\\sdf'", '1', '1.1', 'None', "b'foo'", Ellipsis]),
|
('mixed[', 6, [r"'a\\sdf'", '1', '1.1', 'None', "b'foo'", Ellipsis]),
|
||||||
('mixed[1', 7, ['', '.1']),
|
('mixed[1', 7, ['', '.1']),
|
||||||
|
|
||||||
#('casted["f', 9, ['3"', 'bar"', 'oo"']),
|
('casted["f', 9, ['3"', 'bar"', 'oo"']),
|
||||||
#('casted_mod["f', 13, ['3"', 'bar"', 'oo"', 'uuu"', 'ull"']),
|
('casted["f"', 9, ['3', 'bar', 'oo']),
|
||||||
|
('casted["f3', 10, ['"']),
|
||||||
|
('casted["f3"', 10, ['']),
|
||||||
|
('casted_mod["f', 13, ['3"', 'bar"', 'oo"', 'ull"', 'uuu"']),
|
||||||
|
|
||||||
|
('keywords["', None, ['a"']),
|
||||||
|
('keywords[Non', None, ['e']),
|
||||||
|
('keywords[Fa', None, ['lse']),
|
||||||
|
('keywords[str', None, ['', 's']),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -326,6 +334,7 @@ def test_dict_keys_completions(Script, added_code, column, expected, skip_pre_py
|
|||||||
casted_mod = dict(casted)
|
casted_mod = dict(casted)
|
||||||
casted_mod["fuuu"] = 8
|
casted_mod["fuuu"] = 8
|
||||||
casted_mod["full"] = 8
|
casted_mod["full"] = 8
|
||||||
|
keywords = {None: 1, False: 2, "a": 3}
|
||||||
''')
|
''')
|
||||||
line = None
|
line = None
|
||||||
if isinstance(column, tuple):
|
if isinstance(column, tuple):
|
||||||
|
|||||||
Reference in New Issue
Block a user