mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Fix a bug where parent_context was a value
This commit is contained in:
@@ -118,6 +118,7 @@ class MixedName(compiled.CompiledName):
|
||||
if parent_value is None:
|
||||
parent_context = None
|
||||
else:
|
||||
assert parent_value is not None
|
||||
parent_context = parent_value.as_context()
|
||||
|
||||
if parent_context is None or isinstance(parent_context, MixedContext):
|
||||
@@ -130,7 +131,7 @@ class MixedName(compiled.CompiledName):
|
||||
})
|
||||
|
||||
# TODO use logic from compiled.CompiledObjectFilter
|
||||
access_paths = self.parent_context.access_handle.getattr_paths(
|
||||
access_paths = self._parent_value.access_handle.getattr_paths(
|
||||
self.string_name,
|
||||
default=None
|
||||
)
|
||||
@@ -266,6 +267,8 @@ def _create(inference_state, access_handle, parent_context, *args):
|
||||
compiled_object = create_cached_compiled_object(
|
||||
inference_state,
|
||||
access_handle,
|
||||
# TODO It looks like we have to use the compiled object as a parent context.
|
||||
# Why is that?
|
||||
parent_context=None if parent_context is None
|
||||
else parent_context.compiled_object.as_context() # noqa
|
||||
)
|
||||
|
||||
@@ -296,9 +296,10 @@ class CompiledObject(Value):
|
||||
|
||||
|
||||
class CompiledName(AbstractNameDefinition):
|
||||
def __init__(self, inference_state, parent_context, name):
|
||||
def __init__(self, inference_state, parent_value, name):
|
||||
self._inference_state = inference_state
|
||||
self.parent_context = parent_context
|
||||
self.parent_context = parent_value.as_context()
|
||||
self._parent_value = parent_value
|
||||
self.string_name = name
|
||||
|
||||
def py__doc__(self):
|
||||
@@ -336,7 +337,7 @@ class CompiledName(AbstractNameDefinition):
|
||||
@underscore_memoization
|
||||
def infer(self):
|
||||
return ValueSet([_create_from_name(
|
||||
self._inference_state, self.parent_context, self.string_name
|
||||
self._inference_state, self._parent_value, self.string_name
|
||||
)])
|
||||
|
||||
|
||||
@@ -484,7 +485,11 @@ class CompiledObjectFilter(AbstractFilter):
|
||||
return names
|
||||
|
||||
def _create_name(self, name):
|
||||
return self.name_class(self._inference_state, self.compiled_object, name)
|
||||
return self.name_class(
|
||||
self._inference_state,
|
||||
self.compiled_object,
|
||||
name
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s: %s>" % (self.__class__.__name__, self.compiled_object)
|
||||
|
||||
@@ -409,9 +409,11 @@ class AnonymousInstance(_BaseTreeInstance):
|
||||
|
||||
class CompiledInstanceName(compiled.CompiledName):
|
||||
def __init__(self, inference_state, instance, klass, name):
|
||||
parent_value = klass.parent_context.get_value()
|
||||
assert parent_value is not None, "How? Please reproduce and report"
|
||||
super(CompiledInstanceName, self).__init__(
|
||||
inference_state,
|
||||
klass.parent_context,
|
||||
parent_value,
|
||||
name.string_name
|
||||
)
|
||||
self._instance = instance
|
||||
|
||||
Reference in New Issue
Block a user