mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Also support the not operator.
This commit is contained in:
@@ -217,9 +217,11 @@ def _literals_to_types(evaluator, result):
|
|||||||
def calculate(evaluator, left_result, operator, right_result):
|
def calculate(evaluator, left_result, operator, right_result):
|
||||||
result = []
|
result = []
|
||||||
if left_result is None and right_result:
|
if left_result is None and right_result:
|
||||||
# cases like `-1` or `1 + ~1`
|
# Cases like `-1`, `1 + ~1` or `not X`.
|
||||||
for right in right_result:
|
for right in right_result:
|
||||||
result.append(_factor_calculate(evaluator, operator, right))
|
obj = _factor_calculate(evaluator, operator, right)
|
||||||
|
if obj is not None:
|
||||||
|
result.append(obj)
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
if not left_result or not right_result:
|
if not left_result or not right_result:
|
||||||
@@ -243,6 +245,11 @@ def _factor_calculate(evaluator, operator, right):
|
|||||||
if _is_number(right):
|
if _is_number(right):
|
||||||
if operator == '-':
|
if operator == '-':
|
||||||
return create(evaluator, -right.obj)
|
return create(evaluator, -right.obj)
|
||||||
|
if operator == 'not':
|
||||||
|
value = right.py__bool__()
|
||||||
|
if value is None: # Uncertainty.
|
||||||
|
return None
|
||||||
|
return _keyword_from_value(not value)
|
||||||
return right
|
return right
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -117,9 +117,9 @@ else:
|
|||||||
a = dict
|
a = dict
|
||||||
#? dict
|
#? dict
|
||||||
a
|
a
|
||||||
if (check is not check):
|
if not (check is not check):
|
||||||
a = 1
|
a = 1
|
||||||
#? dict
|
#? int()
|
||||||
a
|
a
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user