[gnome-builder] jedi: minimal attempt to get things working again
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] jedi: minimal attempt to get things working again
- Date: Mon, 28 May 2018 03:20:27 +0000 (UTC)
commit 799a378b96cad5dc9b1093604e76ed362d22f4cc
Author: Christian Hergert <chergert redhat com>
Date: Sun May 27 20:19:34 2018 -0700
jedi: minimal attempt to get things working again
This tries to get some of our jedi code working with recent API changes
in the jedi project.
This is just a minimal fix, and I'd expect some others may be needed for
improved functionality.
Fixes #403
src/plugins/jedi/jedi_plugin.py | 44 +++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/src/plugins/jedi/jedi_plugin.py b/src/plugins/jedi/jedi_plugin.py
index fd8e15d68..052500da1 100644
--- a/src/plugins/jedi/jedi_plugin.py
+++ b/src/plugins/jedi/jedi_plugin.py
@@ -91,8 +91,14 @@ try:
import jedi
from jedi.evaluate.compiled import CompiledObject
from jedi.evaluate.compiled import get_special_object
- from jedi.evaluate.compiled import _create_from_name
- from jedi.evaluate.context import Context
+ try:
+ # 0.12
+ from jedi.evaluate.compiled import create_from_name
+ from jedi.evaluate.base_context import Context
+ except ImportError:
+ # Pre 0.12
+ from jedi.evaluate.compiled import _create_from_name as create_from_name
+ from jedi.evaluate.context import Context
from jedi.evaluate.docstrings import _evaluate_for_statement_string
from jedi.evaluate.imports import Importer
@@ -175,23 +181,31 @@ try:
pass
return module_list
- original_jedi_get_module = jedi.evaluate.compiled.fake.get_module
-
- def patched_jedi_get_module(obj):
- "Work around a weird bug in jedi"
- try:
- return original_jedi_get_module(obj)
- except ImportError as e:
- if e.msg == "No module named 'gi._gobject._gobject'":
- return original_jedi_get_module('gi._gobject')
+ try:
+ # Pre 0.12 workaround
+ # TODO: What needs to be fixed here for 0.12?
+ original_jedi_get_module = jedi.evaluate.compiled.fake.get_module
+ def patched_jedi_get_module(obj):
+ "Work around a weird bug in jedi"
+ try:
+ return original_jedi_get_module(obj)
+ except ImportError as e:
+ if e.msg == "No module named 'gi._gobject._gobject'":
+ return original_jedi_get_module('gi._gobject')
+ jedi.evaluate.compiled.fake.get_module = patched_jedi_get_module
+ except:
+ pass
- jedi.evaluate.compiled.fake.get_module = patched_jedi_get_module
jedi.evaluate.compiled.CompiledObject = PatchedJediCompiledObject
- jedi.evaluate.instance.CompiledBoundMethod = PatchedCompiledBoundMethod
+ try:
+ jedi.evaluate.instance.CompiledBoundMethod = PatchedCompiledBoundMethod
+ except AttributeError:
+ jedi.evaluate.context.instance.CompiledBoundMethod = PatchedCompiledBoundMethod
jedi.evaluate.imports.Importer = PatchedJediImporter
HAS_JEDI = True
-except ImportError:
+except ImportError as ex:
print("jedi not found, python auto-completion not possible.")
+ print(ex)
HAS_JEDI = False
GIR_PATH_LIST = []
@@ -376,7 +390,7 @@ class JediCompletionProvider(Ide.Object, GtkSource.CompletionProvider, Ide.Compl
return False
def do_populate(self, context):
- self.current_word = Ide.CompletionProvider.context_current_word(context)
+ self.current_word = Ide.CompletionProvider.context_current_word(context) or ''
self.current_word_lower = self.current_word.lower()
_, iter = context.get_iter()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]