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))
|
||||
# else: print e.g. could be evaluated like this in Python 2.7
|
||||
elif isinstance(element, tree.Lambda):
|
||||
types = set([er.LambdaWrapper(self, context, element)])
|
||||
elif element.isinstance(er.LambdaWrapper):
|
||||
types = set([element]) # TODO this is no real evaluation.
|
||||
types = set([er.FunctionContext(self, context, element)])
|
||||
elif element.type == 'expr_stmt':
|
||||
types = self.eval_statement(context, element)
|
||||
elif element.type in ('power', 'atom_expr'):
|
||||
@@ -545,7 +543,7 @@ class Evaluator(object):
|
||||
if scope_node == base_node:
|
||||
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_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()
|
||||
|
||||
if not (isinstance(scope, er.FunctionExecution) and
|
||||
isinstance(scope.base, er.LambdaWrapper)):
|
||||
isinstance(scope.base, LambdaWrapper)):
|
||||
names = filter_after_position(names, position, origin)
|
||||
names = [name for name in names
|
||||
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)
|
||||
elif node.type == 'global_stmt':
|
||||
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)
|
||||
# For global_stmt lookups, we only need the first possible scope,
|
||||
# which means the function itself.
|
||||
|
||||
@@ -166,7 +166,8 @@ def _element_calculate(evaluator, left, operator, right):
|
||||
|
||||
def check(obj):
|
||||
"""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.
|
||||
if operator in ('+', '-') and l_is_num != r_is_num \
|
||||
|
||||
@@ -38,11 +38,11 @@ import pkgutil
|
||||
import imp
|
||||
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 import debug
|
||||
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 import compiled
|
||||
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]
|
||||
|
||||
|
||||
class LambdaWrapper(FunctionContext):
|
||||
pass
|
||||
|
||||
|
||||
class FunctionExecutionContext(Executed):
|
||||
"""
|
||||
This class is used to evaluate functions and their returns.
|
||||
@@ -302,7 +298,7 @@ class FunctionExecutionContext(Executed):
|
||||
@recursion.execution_recursion_decorator
|
||||
def get_return_values(self, check_yields=False):
|
||||
funcdef = self.funcdef
|
||||
if isinstance(funcdef, tree.Lambda):
|
||||
if funcdef.type == 'lambda':
|
||||
return self.evaluator.eval_element(self, funcdef.children[-1])
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user