diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 86cca474..cfc7411b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,12 @@ 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) ++++++++++++++++++ diff --git a/docs/docs/repl.rst b/docs/docs/repl.rst index e911e46e..b89230d9 100644 --- a/docs/docs/repl.rst +++ b/docs/docs/repl.rst @@ -1,8 +1,18 @@ .. 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 +Using a custom ``$HOME/.pythonrc.py`` +------------------------------------- + .. autofunction:: jedi.utils.setup_readline diff --git a/jedi/__init__.py b/jedi/__init__.py index a0a78e0e..3eb71318 100644 --- a/jedi/__init__.py +++ b/jedi/__init__.py @@ -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. """ -__version__ = 0, 6, 0 +__version__ = 0, 7, 0 import sys diff --git a/jedi/evaluate.py b/jedi/evaluate.py index cc597cc8..38d3ebc5 100644 --- a/jedi/evaluate.py +++ b/jedi/evaluate.py @@ -787,8 +787,8 @@ def follow_path(path, scope, call_scope, position=None): def filter_private_variable(scope, call_scope, var_name): """private variables begin with a double underline `__`""" - if isinstance(var_name, (str, unicode)) \ - and var_name.startswith('__') and isinstance(scope, er.Instance): + if isinstance(var_name, (str, unicode)) and isinstance(scope, er.Instance)\ + and var_name.startswith('__') and not var_name.endswith('__'): s = call_scope.get_parent_until((pr.Class, er.Instance)) if s != scope and s != scope.base.base: return True diff --git a/jedi/evaluate_representation.py b/jedi/evaluate_representation.py index 85bbcd84..31f8ba67 100644 --- a/jedi/evaluate_representation.py +++ b/jedi/evaluate_representation.py @@ -769,6 +769,8 @@ class Generator(use_metaclass(cache.CachedMetaClass, pr.Base)): none_pos, none_pos) if n in executes_generator: name.parent = self + else: + name.parent = builtin.Builtin.scope names.append(name) debug.dbg('generator names', names) return names diff --git a/jedi/replstartup.py b/jedi/replstartup.py index 73b3f7fd..c535c5e2 100644 --- a/jedi/replstartup.py +++ b/jedi/replstartup.py @@ -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 setup (e.g., ``.bashrc``):: diff --git a/jedi/utils.py b/jedi/utils.py index cd9d032c..57f7827b 100644 --- a/jedi/utils.py +++ b/jedi/utils.py @@ -13,11 +13,14 @@ def setup_readline(): Install Jedi completer to :mod:`readline`. This function setups :mod:`readline` to use Jedi in Python interactive - shell. If you want to use custom ``PYTHONSTARTUP`` file, you can call - this function like this: + shell. If you want to use a custom ``PYTHONSTARTUP`` file (typically + ``$HOME/.pythonrc.py``), you can add this piece of code: - >>> from jedi.utils import setup_readline - >>> setup_readline() + >>> try: + >>> from jedi.utils import setup_readline + >>> setup_readline() + >>> except ImportError: + >>> print('Install Jedi with pip! No autocompletion otherwise.') """ try: diff --git a/test/completion/basic.py b/test/completion/basic.py index 9ce4dad4..41e489e6 100644 --- a/test/completion/basic.py +++ b/test/completion/basic.py @@ -224,6 +224,8 @@ A.__init__ #? ['__init__'] B.__init__ +#? ['__init__'] +int().__init__ # ----------------- # comments diff --git a/test/test_regression.py b/test/test_regression.py index 891c552c..564d4fd1 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -436,6 +436,15 @@ class TestRegression(TestBase): [1, 2, 3, 4, 5, 6, 7, 8, 9, (x)] # <-- here """, '(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):