diff --git a/jedi/api_classes.py b/jedi/api_classes.py index d2a3567a..3fb3d6f0 100644 --- a/jedi/api_classes.py +++ b/jedi/api_classes.py @@ -32,23 +32,29 @@ class BaseOutput(object): self.definition = definition self.is_keyword = isinstance(definition, keywords.Keyword) - # generate the type - self.stripped_definition = self.definition - if isinstance(self.definition, evaluate.InstanceElement): - self.stripped_definition = self.definition.var - self.type = type(self.stripped_definition).__name__ - # generate a path to the definition self.module_path = str(definition.get_parent_until().path) - self.path = [] - if not isinstance(definition, keywords.Keyword): - par = definition + + @property + def type(self): + # generate the type + stripped = self.definition + if isinstance(self.definition, evaluate.InstanceElement): + stripped = self.definition.var + self.type = type(stripped).__name__ + + @property + def path(self): + path = [] + if not isinstance(self.definition, keywords.Keyword): + par = self.definition while par is not None: try: - self.path.insert(0, par.name) + path.insert(0, par.name) except AttributeError: pass par = par.parent + return path @property def module_name(self): diff --git a/jedi/builtin.py b/jedi/builtin.py index 5f1da04f..45a7ac5c 100644 --- a/jedi/builtin.py +++ b/jedi/builtin.py @@ -461,12 +461,11 @@ class Builtin(object): FunctionType = types.FunctionType source = _generate_code(Container, depth=0) parser = parsing.PyFuzzyParser(source, None) - # needed for caching (because of weakref) - module = self.magic_func_module = parser.module + module = parser.module module.parent = self.scope typ = evaluate.follow_path(iter(['FunctionType']), module, module) - self._magic_function_scope = s = typ.pop() + s = self._magic_function_scope = typ.pop() return s