forked from VimPlug/jedi
More small bug fixes.
This commit is contained in:
@@ -266,9 +266,7 @@ class Evaluator(object):
|
|||||||
types.add(compiled.builtin_from_name(self, element.value))
|
types.add(compiled.builtin_from_name(self, element.value))
|
||||||
# else: print e.g. could be evaluated like this in Python 2.7
|
# else: print e.g. could be evaluated like this in Python 2.7
|
||||||
elif isinstance(element, tree.Lambda):
|
elif isinstance(element, tree.Lambda):
|
||||||
types = set([er.LambdaWrapper(self, context, element)])
|
types = set([er.FunctionContext(self, context, element)])
|
||||||
elif element.isinstance(er.LambdaWrapper):
|
|
||||||
types = set([element]) # TODO this is no real evaluation.
|
|
||||||
elif element.type == 'expr_stmt':
|
elif element.type == 'expr_stmt':
|
||||||
types = self.eval_statement(context, element)
|
types = self.eval_statement(context, element)
|
||||||
elif element.type in ('power', 'atom_expr'):
|
elif element.type in ('power', 'atom_expr'):
|
||||||
@@ -545,7 +543,7 @@ class Evaluator(object):
|
|||||||
if scope_node == base_node:
|
if scope_node == base_node:
|
||||||
return base_context
|
return base_context
|
||||||
|
|
||||||
is_funcdef = scope_node.type == 'funcdef'
|
is_funcdef = scope_node.type in ('funcdef', 'lambda')
|
||||||
parent_scope = scope_node.get_parent_scope()
|
parent_scope = scope_node.get_parent_scope()
|
||||||
parent_context = from_scope_node(parent_scope, child_is_funcdef=is_funcdef)
|
parent_context = from_scope_node(parent_scope, child_is_funcdef=is_funcdef)
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ def filter_definition_names(names, origin, position=None):
|
|||||||
scope = stmt.get_parent_scope()
|
scope = stmt.get_parent_scope()
|
||||||
|
|
||||||
if not (isinstance(scope, er.FunctionExecution) and
|
if not (isinstance(scope, er.FunctionExecution) and
|
||||||
isinstance(scope.base, er.LambdaWrapper)):
|
isinstance(scope.base, LambdaWrapper)):
|
||||||
names = filter_after_position(names, position, origin)
|
names = filter_after_position(names, position, origin)
|
||||||
names = [name for name in names
|
names = [name for name in names
|
||||||
if name.is_definition() and not is_comprehension_name(name, origin)]
|
if name.is_definition() and not is_comprehension_name(name, origin)]
|
||||||
@@ -386,7 +386,7 @@ def _name_to_types(evaluator, context, name):
|
|||||||
types = _apply_decorators(evaluator, context, node)
|
types = _apply_decorators(evaluator, context, node)
|
||||||
elif node.type == 'global_stmt':
|
elif node.type == 'global_stmt':
|
||||||
context = evaluator.create_context(context, name)
|
context = evaluator.create_context(context, name)
|
||||||
finder = NameFinder(evaluator, context, str(name))
|
finder = NameFinder(evaluator, context, context, str(name))
|
||||||
filters = finder.get_filters(search_global=True)
|
filters = finder.get_filters(search_global=True)
|
||||||
# For global_stmt lookups, we only need the first possible scope,
|
# For global_stmt lookups, we only need the first possible scope,
|
||||||
# which means the function itself.
|
# which means the function itself.
|
||||||
|
|||||||
@@ -166,7 +166,8 @@ def _element_calculate(evaluator, left, operator, right):
|
|||||||
|
|
||||||
def check(obj):
|
def check(obj):
|
||||||
"""Checks if a Jedi object is either a float or an int."""
|
"""Checks if a Jedi object is either a float or an int."""
|
||||||
return isinstance(obj, instance.CompiledInstance) and obj.name.name_string in ('int', 'float')
|
return isinstance(obj, instance.CompiledInstance) and \
|
||||||
|
obj.name.string_name in ('int', 'float')
|
||||||
|
|
||||||
# Static analysis, one is a number, the other one is not.
|
# Static analysis, one is a number, the other one is not.
|
||||||
if operator in ('+', '-') and l_is_num != r_is_num \
|
if operator in ('+', '-') and l_is_num != r_is_num \
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ import pkgutil
|
|||||||
import imp
|
import imp
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from jedi._compatibility import use_metaclass, unicode, Python3Method, is_py3
|
from jedi._compatibility import use_metaclass, unicode, Python3Method
|
||||||
from jedi.parser import tree
|
from jedi.parser import tree
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
from jedi import common
|
from jedi import common
|
||||||
from jedi.cache import underscore_memoization, cache_star_import
|
from jedi.cache import cache_star_import
|
||||||
from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT
|
from jedi.evaluate.cache import memoize_default, CachedMetaClass, NO_DEFAULT
|
||||||
from jedi.evaluate import compiled
|
from jedi.evaluate import compiled
|
||||||
from jedi.evaluate.compiled import mixed
|
from jedi.evaluate.compiled import mixed
|
||||||
@@ -262,10 +262,6 @@ class FunctionContext(use_metaclass(CachedMetaClass, context.TreeContext)):
|
|||||||
return [ParamName(anon, param.name) for param in self.funcdef.params]
|
return [ParamName(anon, param.name) for param in self.funcdef.params]
|
||||||
|
|
||||||
|
|
||||||
class LambdaWrapper(FunctionContext):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class FunctionExecutionContext(Executed):
|
class FunctionExecutionContext(Executed):
|
||||||
"""
|
"""
|
||||||
This class is used to evaluate functions and their returns.
|
This class is used to evaluate functions and their returns.
|
||||||
@@ -302,7 +298,7 @@ class FunctionExecutionContext(Executed):
|
|||||||
@recursion.execution_recursion_decorator
|
@recursion.execution_recursion_decorator
|
||||||
def get_return_values(self, check_yields=False):
|
def get_return_values(self, check_yields=False):
|
||||||
funcdef = self.funcdef
|
funcdef = self.funcdef
|
||||||
if isinstance(funcdef, tree.Lambda):
|
if funcdef.type == 'lambda':
|
||||||
return self.evaluator.eval_element(self, funcdef.children[-1])
|
return self.evaluator.eval_element(self, funcdef.children[-1])
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user