mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-18 19:45:57 +08:00
enable assignment operators and add substraction support for numbers
This commit is contained in:
@@ -126,8 +126,8 @@ class Evaluator(object):
|
|||||||
|
|
||||||
ass_details = stmt.assignment_details
|
ass_details = stmt.assignment_details
|
||||||
if ass_details and ass_details[0][1] != '=' and not isinstance(stmt,
|
if ass_details and ass_details[0][1] != '=' and not isinstance(stmt,
|
||||||
er.InstanceElement) and False: # TODO don't check for this.
|
er.InstanceElement): # TODO don't check for this.
|
||||||
print('LEFT', ass_details, stmt, stmt.parent)
|
#print('LEFT', ass_details, stmt, stmt.parent)
|
||||||
expr_list, operator = ass_details[0]
|
expr_list, operator = ass_details[0]
|
||||||
name = str(expr_list[0].name)
|
name = str(expr_list[0].name)
|
||||||
start_pos = stmt.start_pos[0] - 1, stmt.start_pos[1] + 30000
|
start_pos = stmt.start_pos[0] - 1, stmt.start_pos[1] + 30000
|
||||||
|
|||||||
@@ -202,4 +202,7 @@ def _element_calculate(left, operator, right):
|
|||||||
elif operator == '+':
|
elif operator == '+':
|
||||||
if is_number(left) and is_number(right) or is_string(left) and is_string(right):
|
if is_number(left) and is_number(right) or is_string(left) and is_string(right):
|
||||||
return [create(left.obj + right.obj)]
|
return [create(left.obj + right.obj)]
|
||||||
|
elif operator == '-':
|
||||||
|
if is_number(left) and is_number(right):
|
||||||
|
return [create(left.obj - right.obj)]
|
||||||
return [left, right]
|
return [left, right]
|
||||||
|
|||||||
@@ -64,3 +64,10 @@ i += 1
|
|||||||
i += 1
|
i += 1
|
||||||
#? float()
|
#? float()
|
||||||
x[i]
|
x[i]
|
||||||
|
|
||||||
|
i = 1
|
||||||
|
i += 1
|
||||||
|
i -= 3
|
||||||
|
i += 1
|
||||||
|
#? int()
|
||||||
|
x[i]
|
||||||
|
|||||||
Reference in New Issue
Block a user