mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +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]
|
||||
|
||||
|
||||
def is_compiled(context):
|
||||
from jedi.evaluate.compiled import CompiledObject, CompiledValue
|
||||
return isinstance(context, (CompiledObject, CompiledValue))
|
||||
|
||||
|
||||
def is_string(context):
|
||||
if context.evaluator.environment.version_info.major == 2:
|
||||
str_classes = (unicode, bytes)
|
||||
else:
|
||||
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):
|
||||
@@ -212,7 +207,7 @@ def is_literal(context):
|
||||
|
||||
|
||||
def _get_safe_value_or_none(context, accept):
|
||||
if is_compiled(context):
|
||||
if context.is_compiled():
|
||||
value = context.get_safe_value(default=None)
|
||||
if isinstance(value, accept):
|
||||
return value
|
||||
|
||||
@@ -21,7 +21,7 @@ from jedi.evaluate.context import ClassContext, FunctionContext
|
||||
from jedi.evaluate.context import iterable
|
||||
from jedi.evaluate.context import TreeInstance
|
||||
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.cache import evaluator_method_cache
|
||||
from jedi.evaluate.gradual.stub_context import VersionInfo
|
||||
@@ -483,7 +483,7 @@ def _eval_comparison_part(evaluator, context, left, operator, right):
|
||||
# `int() % float()`.
|
||||
return ContextSet([left])
|
||||
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.
|
||||
try:
|
||||
return ContextSet([left.execute_operation(right, str_operator)])
|
||||
|
||||
Reference in New Issue
Block a user