Merge branch 'dev' into repl

This commit is contained in:
David Halter
2013-08-05 15:20:10 +04:30
9 changed files with 41 additions and 11 deletions

View File

@@ -3,6 +3,12 @@
Changelog Changelog
--------- ---------
0.7.0 (2013-08-09)
++++++++++++++++++
* switched from LGPL to MIT license
* added an Interpreter class to the API to make autocompletion in REPL possible.
* add sith.py, a new random testing method
0.6.0 (2013-05-14) 0.6.0 (2013-05-14)
++++++++++++++++++ ++++++++++++++++++

View File

@@ -1,8 +1,18 @@
.. include:: ../global.rst .. include:: ../global.rst
How to use Jedi from Python interpreter Jedi autocompletion in the Python interpreter
======================================= =============================================
There are two different options how you can use Jedi autocompletion in
your Python interpreter. One with your custom ``$HOME/.pythonrc.py`` file
and one that uses ``PYTHONSTARTUP``.
Using ``PYTHONSTARTUP``
-----------------------
.. automodule:: jedi.replstartup .. automodule:: jedi.replstartup
Using a custom ``$HOME/.pythonrc.py``
-------------------------------------
.. autofunction:: jedi.utils.setup_readline .. autofunction:: jedi.utils.setup_readline

View File

@@ -34,7 +34,7 @@ As you see Jedi is pretty simple and allows you to concentrate on writing a
good text editor, while still having very good IDE features for Python. good text editor, while still having very good IDE features for Python.
""" """
__version__ = 0, 6, 0 __version__ = 0, 7, 0
import sys import sys

View File

@@ -787,8 +787,8 @@ def follow_path(path, scope, call_scope, position=None):
def filter_private_variable(scope, call_scope, var_name): def filter_private_variable(scope, call_scope, var_name):
"""private variables begin with a double underline `__`""" """private variables begin with a double underline `__`"""
if isinstance(var_name, (str, unicode)) \ if isinstance(var_name, (str, unicode)) and isinstance(scope, er.Instance)\
and var_name.startswith('__') and isinstance(scope, er.Instance): and var_name.startswith('__') and not var_name.endswith('__'):
s = call_scope.get_parent_until((pr.Class, er.Instance)) s = call_scope.get_parent_until((pr.Class, er.Instance))
if s != scope and s != scope.base.base: if s != scope and s != scope.base.base:
return True return True

View File

@@ -769,6 +769,8 @@ class Generator(use_metaclass(cache.CachedMetaClass, pr.Base)):
none_pos, none_pos) none_pos, none_pos)
if n in executes_generator: if n in executes_generator:
name.parent = self name.parent = self
else:
name.parent = builtin.Builtin.scope
names.append(name) names.append(name)
debug.dbg('generator names', names) debug.dbg('generator names', names)
return names return names

View File

@@ -1,6 +1,4 @@
""" """
``PYTHONSTARTUP`` to use Jedi in your Python interpreter.
To use Jedi completion in Python interpreter, add the following in your shell To use Jedi completion in Python interpreter, add the following in your shell
setup (e.g., ``.bashrc``):: setup (e.g., ``.bashrc``)::

View File

@@ -13,11 +13,14 @@ def setup_readline():
Install Jedi completer to :mod:`readline`. Install Jedi completer to :mod:`readline`.
This function setups :mod:`readline` to use Jedi in Python interactive This function setups :mod:`readline` to use Jedi in Python interactive
shell. If you want to use custom ``PYTHONSTARTUP`` file, you can call shell. If you want to use a custom ``PYTHONSTARTUP`` file (typically
this function like this: ``$HOME/.pythonrc.py``), you can add this piece of code:
>>> from jedi.utils import setup_readline >>> try:
>>> setup_readline() >>> from jedi.utils import setup_readline
>>> setup_readline()
>>> except ImportError:
>>> print('Install Jedi with pip! No autocompletion otherwise.')
""" """
try: try:

View File

@@ -224,6 +224,8 @@ A.__init__
#? ['__init__'] #? ['__init__']
B.__init__ B.__init__
#? ['__init__']
int().__init__
# ----------------- # -----------------
# comments # comments

View File

@@ -436,6 +436,15 @@ class TestRegression(TestBase):
[1, 2, 3, 4, 5, 6, 7, 8, 9, (x)] # <-- here [1, 2, 3, 4, 5, 6, 7, 8, 9, (x)] # <-- here
""", '(x)] # <-- here', [None]) """, '(x)] # <-- here', [None])
def test_generator(self):
# Did have some problems with the usage of generator completions this
# way.
s = "def abc():\n" \
" yield 1\n" \
"abc()."
assert self.completions(s)
class TestDocstring(TestBase): class TestDocstring(TestBase):