diff --git a/jedi/evaluate/base_context.py b/jedi/evaluate/base_context.py index c7869f1e..489147f9 100644 --- a/jedi/evaluate/base_context.py +++ b/jedi/evaluate/base_context.py @@ -123,15 +123,19 @@ def iterate_contexts(contexts, contextualized_node=None, is_async=False): ) -class TreeContextWrapper(object): +class ContextWrapper(object): def __init__(self, wrapped_context): self._wrapped_context = wrapped_context - assert wrapped_context.tree_node @safe_property def name(self): from jedi.evaluate.filters import ContextName - return ContextName(self, self._wrapped_context.name.tree_name) + wrapped_name = self._wrapped_context.name + if wrapped_name.tree_name is not None: + return ContextName(self, wrapped_name.tree_name) + else: + from jedi.evaluate.compiled import CompiledContextName + return CompiledContextName(self, wrapped_name.string_name) def __getattr__(self, name): return getattr(self._wrapped_context, name) diff --git a/jedi/evaluate/context/function.py b/jedi/evaluate/context/function.py index 97be4ee6..bdfb1781 100644 --- a/jedi/evaluate/context/function.py +++ b/jedi/evaluate/context/function.py @@ -13,7 +13,7 @@ from jedi.evaluate.arguments import AnonymousArguments from jedi.evaluate.filters import ParserTreeFilter, FunctionExecutionFilter, \ ContextName, AbstractNameDefinition, ParamName from jedi.evaluate.base_context import ContextualizedNode, NO_CONTEXTS, \ - ContextSet, TreeContext, TreeContextWrapper + ContextSet, TreeContext, ContextWrapper from jedi.evaluate.lazy_context import LazyKnownContexts, LazyKnownContext, \ LazyTreeContext from jedi.evaluate.context.typing import TypeVar @@ -296,7 +296,7 @@ class FunctionExecutionContext(TreeContext): return self.get_return_values() -class OverloadedFunctionContext(TreeContextWrapper): +class OverloadedFunctionContext(ContextWrapper): def __init__(self, function, overloaded_functions): super(OverloadedFunctionContext, self).__init__(function) self._overloaded_functions = overloaded_functions diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index 5da99a48..c81e20c5 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -21,7 +21,7 @@ from jedi.evaluate import compiled from jedi.evaluate.context.instance import \ AbstractInstanceContext, CompiledInstance, BoundMethod, InstanceArguments from jedi.evaluate.base_context import ContextualizedNode, \ - NO_CONTEXTS, ContextSet, TreeContextWrapper + NO_CONTEXTS, ContextSet, ContextWrapper from jedi.evaluate.context import ClassContext, ModuleContext, \ FunctionExecutionContext from jedi.evaluate.context import iterable diff --git a/jedi/plugins/typeshed.py b/jedi/plugins/typeshed.py index a513962f..a2946614 100644 --- a/jedi/plugins/typeshed.py +++ b/jedi/plugins/typeshed.py @@ -7,7 +7,7 @@ from jedi.evaluate.cache import evaluator_function_cache from jedi.cache import memoize_method from jedi.parser_utils import get_call_signature_for_any from jedi.evaluate.base_context import ContextSet, iterator_to_context_set, \ - TreeContextWrapper + ContextWrapper from jedi.evaluate.filters import AbstractTreeName, ParserTreeFilter, \ TreeNameDefinition, NameWrapper, MergedFilter from jedi.evaluate.context import ModuleContext, FunctionContext, \ @@ -405,7 +405,7 @@ class StubOnlyModuleContext(ModuleContext): yield f -class StubContextWithCompiled(TreeContextWrapper): +class StubContextWithCompiled(ContextWrapper): def __init__(self, stub_context, compiled_context): super(StubContextWithCompiled, self).__init__(stub_context) self._compiled_context = compiled_context