mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
dict literals are now working (at least the parser)
This commit is contained in:
@@ -43,7 +43,7 @@ class CompiledObject(Base):
|
|||||||
self.doc = inspect.getdoc(obj)
|
self.doc = inspect.getdoc(obj)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s: %s>' % (type(self).__name__, self.obj)
|
return '<%s: %s>' % (type(self).__name__, repr(self.obj))
|
||||||
|
|
||||||
def get_parent_until(self, *args, **kwargs):
|
def get_parent_until(self, *args, **kwargs):
|
||||||
# compiled modules only use functions and classes/methods (2 levels)
|
# compiled modules only use functions and classes/methods (2 levels)
|
||||||
|
|||||||
@@ -1058,13 +1058,12 @@ isinstance(c, (tokenize.Token, Operator)) else unicode(c)
|
|||||||
names_are_set_vars=False):
|
names_are_set_vars=False):
|
||||||
stmt, tok = parse_stmt(token_iterator, allow_comma=True,
|
stmt, tok = parse_stmt(token_iterator, allow_comma=True,
|
||||||
added_breaks=added_breaks)
|
added_breaks=added_breaks)
|
||||||
if not stmt:
|
|
||||||
return None, tok
|
|
||||||
|
|
||||||
for t in stmt._token_list:
|
if stmt is not None:
|
||||||
if isinstance(t, Name):
|
for t in stmt._token_list:
|
||||||
t.parent = stmt
|
if isinstance(t, Name):
|
||||||
stmt._names_are_set_vars = names_are_set_vars
|
t.parent = stmt
|
||||||
|
stmt._names_are_set_vars = names_are_set_vars
|
||||||
return stmt, tok
|
return stmt, tok
|
||||||
|
|
||||||
st = Statement(self._sub_module, token_list, start_pos,
|
st = Statement(self._sub_module, token_list, start_pos,
|
||||||
|
|||||||
@@ -132,11 +132,11 @@ a = [a if 1.0 else '' for a in [1] if [1.0]]
|
|||||||
a[0]
|
a[0]
|
||||||
|
|
||||||
# with a dict literal
|
# with a dict literal
|
||||||
#? int()
|
|
||||||
[a for a,b in {1:2}.items()][0]
|
|
||||||
|
|
||||||
#? str()
|
#? str()
|
||||||
{a:b for a,b in {1:'a', 3:1.0}.items()}[1]
|
[a for a in {1:'x'}][0]
|
||||||
|
|
||||||
|
##? str()
|
||||||
|
{a-1:b for a,b in {1:'a', 3:1.0}.items()}[0]
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# nested list comprehensions
|
# nested list comprehensions
|
||||||
|
|||||||
Reference in New Issue
Block a user