forked from VimPlug/jedi
fix unnessecary bracket stuff
This commit is contained in:
@@ -558,6 +558,7 @@ def follow_call_list(call_list, follow_array=False):
|
|||||||
It is used to evaluate a two dimensional object, that has calls, arrays and
|
It is used to evaluate a two dimensional object, that has calls, arrays and
|
||||||
operators in it.
|
operators in it.
|
||||||
"""
|
"""
|
||||||
|
# TODO remove follow_array?!
|
||||||
def evaluate_list_comprehension(lc, parent=None):
|
def evaluate_list_comprehension(lc, parent=None):
|
||||||
input = lc.input
|
input = lc.input
|
||||||
nested_lc = lc.input.token_list[0]
|
nested_lc = lc.input.token_list[0]
|
||||||
@@ -584,7 +585,8 @@ def follow_call_list(call_list, follow_array=False):
|
|||||||
calls_iterator = iter(call_list)
|
calls_iterator = iter(call_list)
|
||||||
for call in calls_iterator:
|
for call in calls_iterator:
|
||||||
if pr.Array.is_type(call, pr.Array.NOARRAY):
|
if pr.Array.is_type(call, pr.Array.NOARRAY):
|
||||||
result += follow_call_list(call, follow_array=True)
|
result += itertools.chain.from_iterable(follow_statement(s)
|
||||||
|
for s in call)
|
||||||
elif isinstance(call, pr.ListComprehension):
|
elif isinstance(call, pr.ListComprehension):
|
||||||
loop = evaluate_list_comprehension(call)
|
loop = evaluate_list_comprehension(call)
|
||||||
stmt = copy.copy(call.stmt)
|
stmt = copy.copy(call.stmt)
|
||||||
|
|||||||
@@ -763,7 +763,8 @@ class Statement(Simple):
|
|||||||
it and make it nicer, that would be cool :-)
|
it and make it nicer, that would be cool :-)
|
||||||
"""
|
"""
|
||||||
def is_assignment(tok):
|
def is_assignment(tok):
|
||||||
return tok.endswith('=') and not tok in ['>=', '<=', '==', '!=']
|
return tok is not None and tok.endswith('=') \
|
||||||
|
and not tok in ['>=', '<=', '==', '!=']
|
||||||
|
|
||||||
def parse_array(token_iterator, array_type, start_pos, add_el=None):
|
def parse_array(token_iterator, array_type, start_pos, add_el=None):
|
||||||
arr = Array(self.module, start_pos, array_type)
|
arr = Array(self.module, start_pos, array_type)
|
||||||
@@ -782,6 +783,8 @@ class Statement(Simple):
|
|||||||
arr.add_statement(stmt, is_key)
|
arr.add_statement(stmt, is_key)
|
||||||
if break_tok in closing_brackets or is_assignment(break_tok):
|
if break_tok in closing_brackets or is_assignment(break_tok):
|
||||||
break
|
break
|
||||||
|
if arr.type == Array.TUPLE and len(arr) == 1 and break_tok != ',':
|
||||||
|
arr.type = Array.NOARRAY
|
||||||
if not arr.values and maybe_dict:
|
if not arr.values and maybe_dict:
|
||||||
# this is a really special case - empty brackets {} are
|
# this is a really special case - empty brackets {} are
|
||||||
# always dictionaries and not sets.
|
# always dictionaries and not sets.
|
||||||
@@ -802,13 +805,7 @@ class Statement(Simple):
|
|||||||
tok = None
|
tok = None
|
||||||
first = True
|
first = True
|
||||||
for i, tok_temp in token_iterator:
|
for i, tok_temp in token_iterator:
|
||||||
try:
|
if isinstance(tok_temp, (Base)):
|
||||||
token_type, tok, start_tok_pos = tok_temp
|
|
||||||
end_pos = start_tok_pos[0], start_tok_pos[1] + len(tok)
|
|
||||||
if first:
|
|
||||||
first = False
|
|
||||||
start_pos = start_tok_pos
|
|
||||||
except TypeError:
|
|
||||||
# the token is a Name, which has already been parsed
|
# the token is a Name, which has already been parsed
|
||||||
tok = tok_temp
|
tok = tok_temp
|
||||||
if first:
|
if first:
|
||||||
@@ -816,6 +813,12 @@ class Statement(Simple):
|
|||||||
first = False
|
first = False
|
||||||
end_pos = tok.end_pos
|
end_pos = tok.end_pos
|
||||||
else:
|
else:
|
||||||
|
token_type, tok, start_tok_pos = tok_temp
|
||||||
|
end_pos = start_tok_pos[0], start_tok_pos[1] + len(tok)
|
||||||
|
if first:
|
||||||
|
first = False
|
||||||
|
start_pos = start_tok_pos
|
||||||
|
|
||||||
if tok in closing_brackets:
|
if tok in closing_brackets:
|
||||||
level -= 1
|
level -= 1
|
||||||
elif tok in brackets.keys():
|
elif tok in brackets.keys():
|
||||||
|
|||||||
Reference in New Issue
Block a user