mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
helpers.is_compiled -> context.is_compiled
This commit is contained in:
@@ -194,17 +194,12 @@ def predefine_names(context, flow_scope, dct):
|
|||||||
del predefined[flow_scope]
|
del predefined[flow_scope]
|
||||||
|
|
||||||
|
|
||||||
def is_compiled(context):
|
|
||||||
from jedi.evaluate.compiled import CompiledObject, CompiledValue
|
|
||||||
return isinstance(context, (CompiledObject, CompiledValue))
|
|
||||||
|
|
||||||
|
|
||||||
def is_string(context):
|
def is_string(context):
|
||||||
if context.evaluator.environment.version_info.major == 2:
|
if context.evaluator.environment.version_info.major == 2:
|
||||||
str_classes = (unicode, bytes)
|
str_classes = (unicode, bytes)
|
||||||
else:
|
else:
|
||||||
str_classes = (unicode,)
|
str_classes = (unicode,)
|
||||||
return is_compiled(context) and isinstance(context.get_safe_value(default=None), str_classes)
|
return context.is_compiled() and isinstance(context.get_safe_value(default=None), str_classes)
|
||||||
|
|
||||||
|
|
||||||
def is_literal(context):
|
def is_literal(context):
|
||||||
@@ -212,7 +207,7 @@ def is_literal(context):
|
|||||||
|
|
||||||
|
|
||||||
def _get_safe_value_or_none(context, accept):
|
def _get_safe_value_or_none(context, accept):
|
||||||
if is_compiled(context):
|
if context.is_compiled():
|
||||||
value = context.get_safe_value(default=None)
|
value = context.get_safe_value(default=None)
|
||||||
if isinstance(value, accept):
|
if isinstance(value, accept):
|
||||||
return value
|
return value
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from jedi.evaluate.context import ClassContext, FunctionContext
|
|||||||
from jedi.evaluate.context import iterable
|
from jedi.evaluate.context import iterable
|
||||||
from jedi.evaluate.context import TreeInstance
|
from jedi.evaluate.context import TreeInstance
|
||||||
from jedi.evaluate.finder import NameFinder
|
from jedi.evaluate.finder import NameFinder
|
||||||
from jedi.evaluate.helpers import is_string, is_literal, is_number, is_compiled
|
from jedi.evaluate.helpers import is_string, is_literal, is_number
|
||||||
from jedi.evaluate.compiled.access import COMPARISON_OPERATORS
|
from jedi.evaluate.compiled.access import COMPARISON_OPERATORS
|
||||||
from jedi.evaluate.cache import evaluator_method_cache
|
from jedi.evaluate.cache import evaluator_method_cache
|
||||||
from jedi.evaluate.gradual.stub_context import VersionInfo
|
from jedi.evaluate.gradual.stub_context import VersionInfo
|
||||||
@@ -483,7 +483,7 @@ def _eval_comparison_part(evaluator, context, left, operator, right):
|
|||||||
# `int() % float()`.
|
# `int() % float()`.
|
||||||
return ContextSet([left])
|
return ContextSet([left])
|
||||||
elif str_operator in COMPARISON_OPERATORS:
|
elif str_operator in COMPARISON_OPERATORS:
|
||||||
if is_compiled(left) and is_compiled(right):
|
if left.is_compiled() and right.is_compiled():
|
||||||
# Possible, because the return is not an option. Just compare.
|
# Possible, because the return is not an option. Just compare.
|
||||||
try:
|
try:
|
||||||
return ContextSet([left.execute_operation(right, str_operator)])
|
return ContextSet([left.execute_operation(right, str_operator)])
|
||||||
|
|||||||
Reference in New Issue
Block a user