mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
full dictionary suport
This commit is contained in:
23
evaluate.py
23
evaluate.py
@@ -4,14 +4,13 @@ follow_statement -> follow_call -> follow_paths -> follow_path
|
||||
|
||||
`get_names_for_scope` and `get_scopes_for_name` are search functions
|
||||
|
||||
TODO include super classes
|
||||
TODO nonlocal statement
|
||||
TODO doc
|
||||
TODO list comprehensions, priority?
|
||||
TODO care for *args **kwargs
|
||||
TODO annotations
|
||||
TODO annotations ? how ?
|
||||
TODO generators
|
||||
"""
|
||||
from _compatibility import next, literal_eval
|
||||
from _compatibility import next
|
||||
|
||||
import itertools
|
||||
import copy
|
||||
@@ -403,7 +402,6 @@ class Array(object):
|
||||
# otherwise it just ignores the index (e.g. [1+1])
|
||||
i = index.get_only_subelement().name
|
||||
try:
|
||||
print 'index', i
|
||||
return self.get_exact_index_types(i)
|
||||
except (IndexError, KeyError):
|
||||
pass
|
||||
@@ -413,16 +411,19 @@ class Array(object):
|
||||
if self._array.type == parsing.Array.DICT:
|
||||
old_index = index
|
||||
index = None
|
||||
for key_elements in self._array.keys:
|
||||
for i, key_elements in enumerate(self._array.keys):
|
||||
# because we only want the key to be a string
|
||||
if len(key_elements) == 1:
|
||||
try:
|
||||
str_key = key_elements[0].name
|
||||
if old_index == str_key:
|
||||
index = str_key.name
|
||||
break
|
||||
str_key = key_elements.get_code()
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
str_key = key_elements[0].name
|
||||
except AttributeError:
|
||||
str_key = None
|
||||
if old_index == str_key:
|
||||
index = i
|
||||
break
|
||||
if index is None:
|
||||
raise KeyError('No key found in dictionary')
|
||||
values = [self._array[index]]
|
||||
|
||||
@@ -769,8 +769,8 @@ class Call(object):
|
||||
yield y
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s: %s of %s>" % \
|
||||
(self.__class__.__name__, self.name, self.parent)
|
||||
return "<%s: %s>" % \
|
||||
(self.__class__.__name__, self.name)
|
||||
|
||||
|
||||
class Array(Call):
|
||||
@@ -820,6 +820,7 @@ class Array(Call):
|
||||
"""
|
||||
self.type = Array.DICT
|
||||
self.keys.append(self.values.pop())
|
||||
self.values.append([])
|
||||
|
||||
def get_only_subelement(self):
|
||||
"""
|
||||
|
||||
@@ -124,6 +124,7 @@ dic2 = {'asdf': 3, 'b': 'str'}
|
||||
dic2['asdf'].real
|
||||
#? []
|
||||
dic2['asdf'].upper
|
||||
# string literal
|
||||
#? ['real']
|
||||
dic2[r'asdf'].real
|
||||
#? []
|
||||
|
||||
@@ -153,7 +153,7 @@ exe.items
|
||||
def fu(a=1, b="", *args, **kwargs):
|
||||
return a, b, args, kwargs
|
||||
|
||||
exe = fu(list, 1, "", c=set)
|
||||
exe = fu(list, 1, "", c=set, d="")
|
||||
|
||||
#? ['append']
|
||||
exe[0].append
|
||||
@@ -167,3 +167,5 @@ exe[2][0].upper
|
||||
exe[3].items
|
||||
#? ['union']
|
||||
exe[3]['c'].union
|
||||
#? []
|
||||
exe[3]['c'].upper
|
||||
|
||||
Reference in New Issue
Block a user