Skip to content

Commit

Permalink
Merge pull request #315 from immerrr/fix-travis-build
Browse files Browse the repository at this point in the history
Fix travis build
  • Loading branch information
immerrr committed Oct 23, 2018
2 parents b0764f4 + 1a70b6d commit 3817e6f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 27 deletions.
22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
sudo: false
language: python
git:
depth: 3
python:
- "2.7"
- "3.4"
# First python version in this list is the default for matrix.include
# - "3.7"
- "3.6"
- "3.5"
- "3.4"
- "2.7"
env:
matrix:
- EVM_EMACS=emacs-24.3-travis
- EVM_EMACS=emacs-24.4-travis
- EVM_EMACS=emacs-24.5-travis
- EVM_EMACS=emacs-26.1-travis
global:
# Turn on --use-mirrors option everywhere (even in tox):
- PIP_USE_MIRRORS=t
# Use Python version of the one used for running tox
- TOXENV=py
matrix:
allow_failures:
- python: "3.5"
include:
- env: EVM_EMACS=emacs-24.4-travis
- env: EVM_EMACS=emacs-24.5-travis
- env: EVM_EMACS=emacs-25.1-travis
- env: EVM_EMACS=emacs-25.2-travis
- env: EVM_EMACS=emacs-25.3-travis

before_install:
- pip install -q virtualenv tox
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
Expand Down
47 changes: 30 additions & 17 deletions jediepcserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

jedi = None # I will load it later


PY3 = (sys.version_info[0] >= 3)
NEED_ENCODE = not PY3

Expand Down Expand Up @@ -92,20 +91,24 @@ def complete(*args):
return reply


PARAM_PREFIX_RE = re.compile(r'^param\s+')
"""RE to strip unwanted "param " prefix returned by param.description."""

def get_in_function_call(*args):
sig = jedi_script(*args).call_signatures()
call_def = sig[0] if sig else None

if call_def:
return dict(
# p.get_code(False) should do the job. But jedi-vim use replace.
# So follow what jedi-vim does...
params=[p.get_code().replace('\n', '') for p in call_def.params],
index=call_def.index,
call_name=call_def.call_name,
)
else:
return [] # nil
if not call_def:
return []

return dict(
# p.description should do the job. But jedi-vim use replace.
# So follow what jedi-vim does...
params=[PARAM_PREFIX_RE.sub('', p.description).replace('\n', '')
for p in call_def.params],
index=call_def.index,
call_name=call_def.name,
)


def _goto(method, *args):
Expand Down Expand Up @@ -176,10 +179,25 @@ def get_names_recursively(definition, parent=None):


def defined_names(*args):
return list(map(get_names_recursively, jedi.api.defined_names(*args)))
# XXX: there's a bug in Jedi that returns returns definitions from inside
# classes or functions even though all_scopes=False is set by
# default. Hence some additional filtering is in order.
#
# See https://github.com/davidhalter/jedi/issues/1202
top_level_names = [
defn
for defn in jedi.api.names(*args)
if defn.parent().type == 'module'
]
return list(map(get_names_recursively, top_level_names))


def get_module_version(module):
notfound = object()
for key in ['__version__', 'version']:
version = getattr(module, key, notfound)
if version is not notfound:
return version
try:
from pkg_resources import get_distribution, DistributionNotFound
try:
Expand All @@ -189,11 +207,6 @@ def get_module_version(module):
except ImportError:
pass

notfound = object()
for key in ['__version__', 'version']:
version = getattr(module, key, notfound)
if version is not notfound:
return version


def get_jedi_version():
Expand Down
8 changes: 5 additions & 3 deletions test-jedi.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ json.l
(ert-deftest jedi:get-in-function-call-request ()
(with-python-temp-buffer
"
isinstance(obj,
def foobar(qux, quux):
pass
foobar(obj,
"
(goto-char (1- (point-max)))
(destructuring-bind (&key params index call_name)
(jedi-testing:sync (jedi:call-deferred 'get_in_function_call))
(should (equal params '("object" "class_or_type_or_tuple")))
(should (equal params '("qux" "quux")))
(should (equal index 1))
(should (equal call_name "isinstance")))))
(should (equal call_name "foobar")))))

(ert-deftest jedi:goto-request ()
(with-python-temp-buffer
Expand Down

0 comments on commit 3817e6f

Please sign in to comment.