Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the auto-completion asynchronous #306

Merged
merged 9 commits into from
Jan 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ _get_dependency:
dependencies:
rm -rf dependencies/
mkdir dependencies/
$(MAKE) _get_dependency -e REPO=https://github.com/davidhalter/jedi -e TAG=v0.15.1 -e TARGET=jedi
$(MAKE) _get_dependency -e REPO=https://github.com/davidhalter/parso -e TAG=v0.5.1 -e TARGET=parso
$(MAKE) _get_dependency -e REPO=https://github.com/davidhalter/jedi -e TAG=v0.15.2 -e TARGET=jedi
$(MAKE) _get_dependency -e REPO=https://github.com/davidhalter/parso -e TAG=v0.5.2 -e TARGET=parso
patch --dry-run -p0 < jedi_0.15.x.patch
patch -p0 < jedi_0.15.x.patch

Expand Down
2 changes: 1 addition & 1 deletion dependencies/jedi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
good text editor, while still having very good IDE features for Python.
"""

__version__ = '0.15.1'
__version__ = '0.15.2'

from jedi.api import Script, Interpreter, set_debug_function, \
preload_module, names
Expand Down
63 changes: 63 additions & 0 deletions dependencies/jedi/_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@
py_version = int(str(sys.version_info[0]) + str(sys.version_info[1]))


if sys.version_info[:2] < (3, 5):
"""
A super-minimal shim around listdir that behave like
scandir for the information we need.
"""
class _DirEntry:

def __init__(self, name, basepath):
self.name = name
self.basepath = basepath

def is_dir(self):
path_for_name = os.path.join(self.basepath, self.name)
return os.path.isdir(path_for_name)

def scandir(dir):
return [_DirEntry(name, dir) for name in os.listdir(dir)]
else:
from os import scandir


class DummyFile(object):
def __init__(self, loader, string):
self.loader = loader
Expand Down Expand Up @@ -663,3 +684,45 @@ def _exitfunc(cls):

atexit.register(finalize._exitfunc)
weakref.finalize = finalize


if is_py3 and sys.version_info[1] > 5:
from inspect import unwrap
else:
# Only Python >=3.6 does properly limit the amount of unwraps. This is very
# relevant in the case of unittest.mock.patch.
# Below is the implementation of Python 3.7.
def unwrap(func, stop=None):
"""Get the object wrapped by *func*.

Follows the chain of :attr:`__wrapped__` attributes returning the last
object in the chain.

*stop* is an optional callback accepting an object in the wrapper chain
as its sole argument that allows the unwrapping to be terminated early if
the callback returns a true value. If the callback never returns a true
value, the last object in the chain is returned as usual. For example,
:func:`signature` uses this to stop unwrapping if any object in the
chain has a ``__signature__`` attribute defined.

:exc:`ValueError` is raised if a cycle is encountered.

"""
if stop is None:
def _is_wrapper(f):
return hasattr(f, '__wrapped__')
else:
def _is_wrapper(f):
return hasattr(f, '__wrapped__') and not stop(f)
f = func # remember the original func for error reporting
# Memoise by id to tolerate non-hashable objects, but store objects to
# ensure they aren't destroyed, which would allow their IDs to be reused.
memo = {id(f): f}
recursion_limit = sys.getrecursionlimit()
while _is_wrapper(func):
func = func.__wrapped__
id_func = id(func)
if (id_func in memo) or (len(memo) >= recursion_limit):
raise ValueError('wrapper loop when unwrapping {!r}'.format(f))
memo[id_func] = func
return func
Loading