mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Fix dict completions for inherited dicts, fixes #1631
This commit is contained in:
@@ -71,6 +71,13 @@ class MixedObject(ValueWrapper):
|
|||||||
else:
|
else:
|
||||||
return self.compiled_value.get_safe_value(default)
|
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):
|
def py__simple_getitem__(self, index):
|
||||||
python_object = self.compiled_value.access_handle.access._obj
|
python_object = self.compiled_value.access_handle.access._obj
|
||||||
if type(python_object) in ALLOWED_GETITEM_TYPES:
|
if type(python_object) in ALLOWED_GETITEM_TYPES:
|
||||||
|
|||||||
@@ -594,12 +594,18 @@ def test_param_annotation_completion(class_is_findable):
|
|||||||
('mixed[Non', 9, ['e']),
|
('mixed[Non', 9, ['e']),
|
||||||
|
|
||||||
('implicit[10', None, ['00']),
|
('implicit[10', None, ['00']),
|
||||||
|
|
||||||
|
('inherited["', None, ['blablu"']),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_dict_completion(code, column, expected):
|
def test_dict_completion(code, column, expected):
|
||||||
strs = {'asdf': 1, u"""foo""": 2, r'fbar': 3}
|
strs = {'asdf': 1, u"""foo""": 2, r'fbar': 3}
|
||||||
mixed = {1: 2, 1.10: 4, None: 6, r'a\sdf': 8, b'foo': 9}
|
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}}]
|
namespaces = [locals(), {'implicit': {1000: 3}}]
|
||||||
comps = jedi.Interpreter(code, namespaces).complete(column=column)
|
comps = jedi.Interpreter(code, namespaces).complete(column=column)
|
||||||
if Ellipsis in expected:
|
if Ellipsis in expected:
|
||||||
|
|||||||
Reference in New Issue
Block a user