forked from VimPlug/jedi
NO_CONTEXTS -> NO_VALUES
This commit is contained in:
@@ -11,7 +11,7 @@ from parso import ParserSyntaxError, parse
|
||||
|
||||
from jedi._compatibility import force_unicode
|
||||
from jedi.inference.cache import infer_state_method_cache
|
||||
from jedi.inference.base_value import ContextSet, NO_CONTEXTS
|
||||
from jedi.inference.base_value import ContextSet, NO_VALUES
|
||||
from jedi.inference.gradual.typing import TypeVar, LazyGenericClass, \
|
||||
AbstractAnnotatedClass
|
||||
from jedi.inference.gradual.typing import GenericClass
|
||||
@@ -47,7 +47,7 @@ def infer_annotation(value, annotation):
|
||||
def _infer_annotation_string(value, string, index=None):
|
||||
node = _get_forward_reference_node(value, string)
|
||||
if node is None:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
value_set = value.infer_node(node)
|
||||
if index is not None:
|
||||
@@ -142,11 +142,11 @@ def _infer_param(execution_value, param):
|
||||
node = param.parent.parent
|
||||
comment = parser_utils.get_following_comment_same_line(node)
|
||||
if comment is None:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
match = re.match(r"^#\s*type:\s*\(([^#]*)\)\s*->", comment)
|
||||
if not match:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
params_comments = _split_comment_param_declaration(match.group(1))
|
||||
|
||||
# Find the specific param being investigated
|
||||
@@ -162,10 +162,10 @@ def _infer_param(execution_value, param):
|
||||
if isinstance(execution_value.var_args, InstanceArguments):
|
||||
if index == 0:
|
||||
# Assume it's self, which is already handled
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
index -= 1
|
||||
if index >= len(params_comments):
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
param_comment = params_comments[index]
|
||||
return _infer_annotation_string(
|
||||
@@ -203,18 +203,18 @@ def infer_return_types(function_execution_value):
|
||||
node = function_execution_value.tree_node
|
||||
comment = parser_utils.get_following_comment_same_line(node)
|
||||
if comment is None:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
match = re.match(r"^#\s*type:\s*\([^#]*\)\s*->\s*([^#]*)", comment)
|
||||
if not match:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
return _infer_annotation_string(
|
||||
function_execution_value.function_value.get_default_param_value(),
|
||||
match.group(1).strip()
|
||||
).execute_annotation()
|
||||
if annotation is None:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
value = function_execution_value.function_value.get_default_param_value()
|
||||
unknown_type_vars = list(find_unknown_type_vars(value, annotation))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from jedi import debug
|
||||
from jedi.inference.base_value import ContextSet, \
|
||||
NO_CONTEXTS
|
||||
NO_VALUES
|
||||
from jedi.inference.utils import to_list
|
||||
from jedi.inference.gradual.stub_value import StubModuleContext
|
||||
|
||||
@@ -16,7 +16,7 @@ def _stub_to_python_value_set(stub_value, ignore_compiled=False):
|
||||
|
||||
qualified_names = stub_value.get_qualified_names()
|
||||
if qualified_names is None:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
was_bound_method = stub_value.is_bound_method()
|
||||
if was_bound_method:
|
||||
@@ -60,7 +60,7 @@ def _try_stub_to_python_names(names, prefer_stub_to_compiled=False):
|
||||
|
||||
name_list = name.get_qualified_names()
|
||||
if name_list is None:
|
||||
values = NO_CONTEXTS
|
||||
values = NO_VALUES
|
||||
else:
|
||||
values = _infer_from_stub(
|
||||
module,
|
||||
@@ -112,7 +112,7 @@ def _python_to_stub_names(names, fallback_to_python=False):
|
||||
continue
|
||||
|
||||
name_list = name.get_qualified_names()
|
||||
stubs = NO_CONTEXTS
|
||||
stubs = NO_VALUES
|
||||
if name_list is not None:
|
||||
stub_module = _load_stub_module(module)
|
||||
if stub_module is not None:
|
||||
@@ -150,7 +150,7 @@ def convert_values(values, only_stubs=False, prefer_stubs=False, ignore_compiled
|
||||
if only_stubs or prefer_stubs:
|
||||
return ContextSet.from_sets(
|
||||
to_stub(value)
|
||||
or (ContextSet({value}) if prefer_stubs else NO_CONTEXTS)
|
||||
or (ContextSet({value}) if prefer_stubs else NO_VALUES)
|
||||
for value in values
|
||||
)
|
||||
else:
|
||||
@@ -173,7 +173,7 @@ def to_stub(value):
|
||||
qualified_names = value.get_qualified_names()
|
||||
stub_module = _load_stub_module(value.get_root_value())
|
||||
if stub_module is None or qualified_names is None:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
was_bound_method = value.is_bound_method()
|
||||
if was_bound_method:
|
||||
|
||||
@@ -5,7 +5,7 @@ from functools import wraps
|
||||
from jedi.file_io import FileIO
|
||||
from jedi._compatibility import FileNotFoundError, cast_path
|
||||
from jedi.parser_utils import get_cached_code_lines
|
||||
from jedi.inference.base_value import ContextSet, NO_CONTEXTS
|
||||
from jedi.inference.base_value import ContextSet, NO_VALUES
|
||||
from jedi.inference.gradual.stub_value import TypingModuleWrapper, StubModuleContext
|
||||
|
||||
_jedi_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
@@ -150,7 +150,7 @@ def _try_to_load_stub(infer_state, import_names, python_value_set,
|
||||
if parent_module_value is None and len(import_names) > 1:
|
||||
try:
|
||||
parent_module_value = _try_to_load_stub_cached(
|
||||
infer_state, import_names[:-1], NO_CONTEXTS,
|
||||
infer_state, import_names[:-1], NO_VALUES,
|
||||
parent_module_value=None, sys_path=sys_path)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@@ -9,7 +9,7 @@ from jedi._compatibility import unicode, force_unicode
|
||||
from jedi import debug
|
||||
from jedi.inference.cache import infer_state_method_cache
|
||||
from jedi.inference.compiled import builtin_from_name
|
||||
from jedi.inference.base_value import ContextSet, NO_CONTEXTS, Context, \
|
||||
from jedi.inference.base_value import ContextSet, NO_VALUES, Context, \
|
||||
iterator_to_value_set, ContextWrapper, LazyContextWrapper
|
||||
from jedi.inference.lazy_value import LazyKnownContexts
|
||||
from jedi.inference.value.iterable import SequenceLiteralContext
|
||||
@@ -286,7 +286,7 @@ class _ContainerBase(_WithIndexBase):
|
||||
return values
|
||||
|
||||
debug.warning('No param #%s found for annotation %s', index, self._index_value)
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
|
||||
class Callable(_ContainerBase):
|
||||
@@ -313,7 +313,7 @@ class Tuple(_ContainerBase):
|
||||
return self._get_getitem_values(index).execute_annotation()
|
||||
|
||||
debug.dbg('The getitem type on Tuple was %s' % index)
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
def py__iter__(self, valueualized_node=None):
|
||||
if self._is_homogenous():
|
||||
@@ -343,7 +343,7 @@ class Protocol(_ContainerBase):
|
||||
class Any(_BaseTypingContext):
|
||||
def execute_annotation(self):
|
||||
debug.warning('Used Any - returned no results')
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
|
||||
class TypeVarClass(_BaseTypingContext):
|
||||
@@ -355,7 +355,7 @@ class TypeVarClass(_BaseTypingContext):
|
||||
# The name must be given, otherwise it's useless.
|
||||
if var_name is None or key is not None:
|
||||
debug.warning('Found a variable without a name %s', arguments)
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
return ContextSet([TypeVar.create_cached(
|
||||
self.infer_state,
|
||||
@@ -424,7 +424,7 @@ class TypeVar(_BaseTypingContext):
|
||||
if self._constraints_lazy_values:
|
||||
return self.constraints
|
||||
debug.warning('Tried to infer the TypeVar %s without a given type', self._var_name)
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
|
||||
def is_same_class(self, other):
|
||||
# Everything can match an undefined type var.
|
||||
@@ -466,7 +466,7 @@ class NewTypeFunction(_BaseTypingContext):
|
||||
next(ordered_args, (None, None))
|
||||
_, second_arg = next(ordered_args, (None, None))
|
||||
if second_arg is None:
|
||||
return NO_CONTEXTS
|
||||
return NO_VALUES
|
||||
return ContextSet(
|
||||
NewType(
|
||||
self.infer_state,
|
||||
@@ -602,7 +602,7 @@ class AbstractAnnotatedClass(ClassMixin, ContextWrapper):
|
||||
changed = False
|
||||
new_generics = []
|
||||
for generic_set in self.get_generics():
|
||||
values = NO_CONTEXTS
|
||||
values = NO_VALUES
|
||||
for generic in generic_set:
|
||||
if isinstance(generic, (AbstractAnnotatedClass, TypeVar)):
|
||||
result = generic.define_generics(type_var_dict)
|
||||
@@ -678,7 +678,7 @@ class LazyAnnotatedBaseClass(object):
|
||||
def _remap_type_vars(self, base):
|
||||
filter = self._class_value.get_type_var_filter()
|
||||
for type_var_set in base.get_generics():
|
||||
new = NO_CONTEXTS
|
||||
new = NO_VALUES
|
||||
for type_var in type_var_set:
|
||||
if isinstance(type_var, TypeVar):
|
||||
names = filter.get(type_var.py__name__())
|
||||
|
||||
Reference in New Issue
Block a user