From e8bda041946e916ed74f98a656292e7b9539b074 Mon Sep 17 00:00:00 2001 From: Cyrille Froehlich Date: Sat, 30 Jan 2021 00:32:16 +0900 Subject: [PATCH] [WIP] Prepare compat --- jedi-core.el | 8 ++++---- jediepcserver.py | 8 ++++---- setup.py | 3 ++- tox.ini | 5 +++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/jedi-core.el b/jedi-core.el index c50e5aa..61e839b 100644 --- a/jedi-core.el +++ b/jedi-core.el @@ -714,15 +714,15 @@ See: https://github.com/tkf/emacs-jedi/issues/54" (substring-no-properties (or (buffer-file-name) ""))) (defun jedi:call-deferred (method-name) - "Call ``Script(...).METHOD-NAME`` and return a deferred object." + "Call ``Script(...).METHOD-NAME(...)`` and return a deferred object." (let ((source (buffer-substring-no-properties (point-min) (point-max))) + (source-path (jedi:-buffer-file-name)) ;; line=0 is an error for jedi, but is possible for empty buffers. (line (max 1 (count-lines (point-min) (min (1+ (point)) (point-max))))) - (column (- (point) (line-beginning-position))) - (source-path (jedi:-buffer-file-name))) + (column (- (point) (line-beginning-position)))) (epc:call-deferred (jedi:get-epc) method-name - (list source line column source-path)))) + (list source source-path line column)))) ;;; Completion diff --git a/jediepcserver.py b/jediepcserver.py index 5d613d8..2c805cc 100755 --- a/jediepcserver.py +++ b/jediepcserver.py @@ -217,14 +217,14 @@ def _wrap_completion_result(comp): description=candidates_description(comp), symbol=candidate_symbol(comp), ) - source, line, column, source_path = args + source, source_path, line, column = args return [ _wrap_completion_result(comp) for comp in self.jedi_script(source, source_path).complete(line, column) ] def get_in_function_call(self, *args): - source, line, column, source_path = args + source, source_path, line, column = args sig = self.jedi_script(source, source_path).get_signatures(line, column) call_def = sig[0] if sig else None @@ -251,7 +251,7 @@ def _goto(self, method, *args): # `definitions` is a list. Each element is an instances of # `jedi.api_classes.BaseOutput` subclass, i.e., # `jedi.api_classes.RelatedName` or `jedi.api_classes.Definition`. - source, line, column, source_path = args + source, source_path, line, column = args definitions = method(self.jedi_script(source, source_path), line, column) return [dict( column=d.column, @@ -268,7 +268,7 @@ def related_names(self, *args): return self._goto(jedi.Script.get_references, *args) def get_definition(self, *args): - source, line, column, source_path = args + source, source_path, line, column = args definitions = self.jedi_script(source, source_path).infer(line, column) return [definition_to_dict(d) for d in definitions] diff --git a/setup.py b/setup.py index a9c465b..b55d2c2 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,8 @@ version='0.3.0', py_modules=['jediepcserver'], install_requires=[ - "jedi>=0.18.0", + "jedi>=0.18.0;python_version>3.5", + "jedi<0.18.0;python_version<=3.5", "epc>=0.0.4", "argparse", ], diff --git a/tox.ini b/tox.ini index a5c30a4..ac872fe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,11 @@ [tox] -envlist = py36, py37, py38, py39 +envlist = py27, py35, py36, py37, py38, py39 [testenv] deps = pytest - jedi>=0.18.0 + jedi>=0.18.0;python_version>3.5 + jedi<0.18.0;python_version<=3.5 commands = py.test {posargs} test_jediepcserver.py [pytest]