From 79ced22a37dc33f1e4dbfeea198266b855c2c44e Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 29 Jan 2018 19:18:54 +0100 Subject: [PATCH] Handle the module_path better for namespaces See also discussion in davidhalter/jedi#1033 --- pythonx/jedi_vim.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index d68ffd6..4be834e 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -294,8 +294,12 @@ def goto(mode="goto", no_output=False): for d in definitions: if d.in_builtin_module(): lst.append(dict(text=PythonToVimStr('Builtin ' + d.description))) + elif d.module_path is None: + # Typically a namespace, in the future maybe other things as + # well. + lst.append(dict(text=PythonToVimStr(d.description))) else: - lst.append(dict(filename=PythonToVimStr(d.module_path), + lst.append(dict(filename=PythonToVimStr(d.module_path or ''), lnum=d.line, col=d.column + 1, text=PythonToVimStr(d.description))) vim_eval('setqflist(%s)' % repr(lst)) @@ -580,6 +584,7 @@ def do_rename(replace, orig=None): continue if os.path.abspath(vim.current.buffer.name) != r.module_path: + assert r.module_path is not None result = new_buffer(r.module_path) if not result: echo_highlight("Jedi-vim: failed to create buffer window for {0}!".format(r.module_path))