mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Cleaned up create_context for methods
Some improvements made a lot of things clearer about function/method contexts, therefore the code is now clearer.
This commit is contained in:
@@ -433,18 +433,15 @@ class Evaluator(object):
|
||||
parent_context = from_scope_node(parent_scope)
|
||||
|
||||
if is_funcdef:
|
||||
parent_was_class = parent_context.is_class()
|
||||
if parent_was_class:
|
||||
parent_context = AnonymousInstance(
|
||||
self, parent_context.parent_context, parent_context)
|
||||
|
||||
func = FunctionContext.from_context(parent_context, scope_node)
|
||||
|
||||
if parent_was_class:
|
||||
if parent_context.is_class():
|
||||
instance = AnonymousInstance(
|
||||
self, parent_context.parent_context, parent_context)
|
||||
func = BoundMethod(
|
||||
instance=parent_context,
|
||||
instance=instance,
|
||||
function=func
|
||||
)
|
||||
|
||||
if is_nested and not node_is_object:
|
||||
return func.get_function_execution()
|
||||
return func
|
||||
|
||||
@@ -13,7 +13,7 @@ from jedi.evaluate.arguments import AnonymousArguments
|
||||
from jedi.evaluate.filters import ParserTreeFilter, FunctionExecutionFilter
|
||||
from jedi.evaluate.names import ContextName, AbstractNameDefinition, ParamName
|
||||
from jedi.evaluate.base_context import ContextualizedNode, NO_CONTEXTS, \
|
||||
ContextSet, TreeContext, ContextWrapper, LazyContextWrapper
|
||||
ContextSet, TreeContext, ContextWrapper
|
||||
from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \
|
||||
LazyTreeContext
|
||||
from jedi.evaluate.context import iterable
|
||||
|
||||
Reference in New Issue
Block a user