From c4587c2140e36d42124964c1d74941e19bd243d7 2016-05-18 17:17:50 From: Matthias Bussonnier Date: 2016-05-18 17:17:50 Subject: [PATCH] Remove Jedi integration before 5.0 There are a few bugs, and things to iron out that we will likely not have the chance to do before 5.0, do deactivating (removing) jedi integration for now, we can always resurrect the current code from git history. --- diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 21c9110..cbff2aa 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -77,10 +77,6 @@ from IPython.utils.process import arg_split from IPython.utils.py3compat import builtin_mod, string_types, PY3, cast_unicode_py2 from traitlets import Bool, Enum, observe -import jedi -import jedi.api.helpers -import jedi.parser.user_context - #----------------------------------------------------------------------------- # Globals #----------------------------------------------------------------------------- @@ -649,6 +645,7 @@ class IPCompleter(Completer): # All active matcher routines for completion self.matchers = [ + self.python_matches, self.file_matches, self.magic_matches, self.python_func_kw_matches, @@ -768,60 +765,6 @@ class IPCompleter(Completer): comp += [ pre+m for m in line_magics if m.startswith(bare_text)] return [cast_unicode_py2(c) for c in comp] - def python_jedi_matches(self, text, line_buffer, cursor_pos): - """Match attributes or global Python names using Jedi.""" - if line_buffer.startswith('aimport ') or line_buffer.startswith('%aimport '): - return () - namespaces = [] - if self.namespace is None: - import __main__ - namespaces.append(__main__.__dict__) - else: - namespaces.append(self.namespace) - if self.global_namespace is not None: - namespaces.append(self.global_namespace) - - # cursor_pos is an it, jedi wants line and column - - interpreter = jedi.Interpreter(line_buffer, namespaces, column=cursor_pos) - path = jedi.parser.user_context.UserContext(line_buffer, \ - (1, len(line_buffer))).get_path_until_cursor() - path, dot, like = jedi.api.helpers.completion_parts(path) - if text.startswith('.'): - # text will be `.` on completions like `a[0].` - before = dot - else: - before = line_buffer[:len(line_buffer) - len(like)] - - - def trim_start(completion): - """completions need to start with `text`, trim the beginning until it does""" - ltext = text.lower() - lcomp = completion.lower() - if ltext in lcomp and not (lcomp.startswith(ltext)): - start_index = lcomp.index(ltext) - if cursor_pos: - if start_index >= cursor_pos: - start_index = min(start_index, cursor_pos) - return completion[start_index:] - return completion - - completions = interpreter.completions() - - completion_text = [c.name_with_symbols for c in completions] - - if self.omit__names: - if self.omit__names == 1: - # true if txt is _not_ a __ name, false otherwise: - no__name = lambda txt: not txt.startswith('__') - else: - # true if txt is _not_ a _ name, false otherwise: - no__name = lambda txt: not txt.startswith('_') - completion_text = filter(no__name, completion_text) - - - return [trim_start(before + c_text) for c_text in completion_text] - def python_matches(self, text): """Match attributes or global python names""" @@ -1255,8 +1198,6 @@ class IPCompleter(Completer): # different types of objects. The rlcomplete() method could then # simply collapse the dict into a list for readline, but we'd have # richer completion semantics in other evironments. - self.matches.extend(self.python_jedi_matches(text, line_buffer, cursor_pos)) - self.matches = sorted(set(self.matches), key=completions_sorting_key) return text, self.matches diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py index 1ef7d3f..4f3ff80 100644 --- a/IPython/core/tests/test_completer.py +++ b/IPython/core/tests/test_completer.py @@ -279,20 +279,11 @@ def test_greedy_completions(): _,c = ip.complete('.', line=line, cursor_pos=cursor_pos) nt.assert_in(expect, c, message%c) - yield _, 'a[0].', 5, '.real', "Should have completed on a[0].: %s" - yield _, 'a[0].r', 6, '.real', "Should have completed on a[0].r: %s" + yield _, 'a[0].', 5, 'a[0].real', "Should have completed on a[0].: %s" + yield _, 'a[0].r', 6, 'a[0].real', "Should have completed on a[0].r: %s" if sys.version_info > (3,4): - yield _, 'a[0].from_', 10, '.from_bytes', "Should have completed on a[0].from_: %s" - - - def _2(): - # jedi bug, this will be empty, makeitfail for now, - # once jedi is fixed, switch to assert_in - # https://github.com/davidhalter/jedi/issues/718 - _,c = ip.complete('.',line='a[0].from', cursor_pos=9) - nt.assert_not_in('.from_bytes', c, "Should not have completed on a[0].from (jedi bug), if fails, update test to assert_in: %s"%c) - yield _2 + yield _, 'a[0].from_', 10, 'a[0].from_bytes', "Should have completed on a[0].from_: %s" diff --git a/setup.py b/setup.py index b0c0151..ab74fb8 100755 --- a/setup.py +++ b/setup.py @@ -191,7 +191,6 @@ extras_require = dict( ) install_requires = [ 'setuptools>=18.5', - 'jedi', 'decorator', 'pickleshare', 'simplegeneric>0.8',