1
0
forked from VimPlug/jedi

Get the first dict completions passing

This commit is contained in:
Dave Halter
2019-09-22 11:13:56 +02:00
parent e86a2ec566
commit e8afb46cde
5 changed files with 69 additions and 31 deletions

19
jedi/api/dicts.py Normal file
View File

@@ -0,0 +1,19 @@
from jedi.inference.names import AbstractArbitraryName
_sentinel = object()
class F(AbstractArbitraryName):
api_type = u'path'
is_value_name = False
def completions_for_dicts(dicts, literal_string):
for dct in dicts:
if dct.array_type == 'dict':
for key in dct.get_key_values():
dict_key = key.get_safe_value(default=_sentinel)
if dict_key is not _sentinel:
dict_key_str = str(dict_key)
if dict_key_str.startswith(literal_string):
yield F(dct.inference_state, dict_key_str[len(literal_string):])