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