From cef58f89a807891353eb0872dbde4efa26d07643 Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 1 Aug 2013 10:23:22 +0200 Subject: [PATCH 1/6] generator problem test --- test/test_regression.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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): From 68d02df01770d4788a46434761e0304b06d28814 Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 1 Aug 2013 15:49:52 +0200 Subject: [PATCH 2/6] fix a parent problem with generators --- jedi/evaluate_representation.py | 2 ++ 1 file changed, 2 insertions(+) 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 From 997e5060381c1b597adbfe98584f80e8282cdbef Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 2 Aug 2013 15:10:15 +0200 Subject: [PATCH 3/6] fix a magic method problem --- jedi/evaluate.py | 4 ++-- test/completion/basic.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) 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/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 From a118b001cc64475db21b8bb54042a1985b7f4cd4 Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 2 Aug 2013 15:38:39 +0200 Subject: [PATCH 4/6] version bump to 0.7 --- jedi/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From e287bf9bca799259b4bc5987e95fa38ece021e89 Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 2 Aug 2013 15:45:47 +0200 Subject: [PATCH 5/6] changelog for version 0.7.0 --- CHANGELOG.rst | 6 ++++++ 1 file changed, 6 insertions(+) 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) ++++++++++++++++++ From cea1d265a65d2c58cc21905c436431ffe8eeb088 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 5 Aug 2013 15:18:24 +0430 Subject: [PATCH 6/6] repl documentation, adds @asmeurer suggestions --- docs/docs/repl.rst | 14 ++++++++++++-- jedi/replstartup.py | 2 -- jedi/utils.py | 11 +++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) 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/replstartup.py b/jedi/replstartup.py index 40ee77da..828e090e 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 37aa2225..50b0cc30 100644 --- a/jedi/utils.py +++ b/jedi/utils.py @@ -93,11 +93,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: