Skip to content

Commit

Permalink
Fix dict completions for inherited dicts, fixes #1631
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed Jul 14, 2020
1 parent 7f3a7db commit 9957374
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jedi/inference/compiled/mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def get_safe_value(self, default=_sentinel):
else:
return self.compiled_value.get_safe_value(default)

@property
def array_type(self):
return self.compiled_value.array_type

def get_key_values(self):
return self.compiled_value.get_key_values()

def py__simple_getitem__(self, index):
python_object = self.compiled_value.access_handle.access._obj
if type(python_object) in ALLOWED_GETITEM_TYPES:
Expand Down
6 changes: 6 additions & 0 deletions test/test_api/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,18 @@ class Foo:
('mixed[Non', 9, ['e']),
('implicit[10', None, ['00']),
('inherited["', None, ['blablu"']),
]
)
def test_dict_completion(code, column, expected):
strs = {'asdf': 1, u"""foo""": 2, r'fbar': 3}
mixed = {1: 2, 1.10: 4, None: 6, r'a\sdf': 8, b'foo': 9}

class Inherited(dict):
pass
inherited = Inherited(blablu=3)

namespaces = [locals(), {'implicit': {1000: 3}}]
comps = jedi.Interpreter(code, namespaces).complete(column=column)
if Ellipsis in expected:
Expand Down

0 comments on commit 9957374

Please sign in to comment.