Merge branch 'repl' into dev

This commit is contained in:
David Halter
2013-08-06 10:57:24 +04:30
5 changed files with 30 additions and 16 deletions

View File

@@ -6,6 +6,16 @@ are ok in the master branch.
3. Add your name to AUTHORS.txt
4. Push to your fork and submit a **pull request to the dev branch**.
My **master** branch is a 100% stable (should be). I only push to it after I am
certain that things are working out. Many people are using Jedi directly from
the github master branch.
**Please use PEP8 to style your code.**
Changing Issues to Pull Requests (Github)
-----------------------------------------
If you have have previously filed a GitHub issue and want to contribute code
that addresses that issue, we prefer it if you use
[hub](https://github.com/github/hub) to convert your existing issue to a pull
@@ -16,9 +26,3 @@ and then issue the following command:
It's no strict requirement though, if you don't have hub installed or prefer to
use the web interface, then feel free to post a traditional pull request.
My **master** branch is a 100% stable (should be). I only push to it after I am
certain that things are working out. Many people are using Jedi directly from
the github master branch.
Please use PEP8 to style your code.

View File

@@ -138,11 +138,11 @@ class Script(object):
if (u.relative_count > 0 or u.from_ns) and not re.search(
r'(,|from)\s*$|import\s+$', completion_line):
completions += ((k, bs) for k
in keywords.get_keywords('import'))
in keywords.keyword_names('import'))
if not path and not isinstance(u, pr.Import):
# add keywords
completions += ((k, bs) for k in keywords.get_keywords(
completions += ((k, bs) for k in keywords.keyword_names(
all=True))
needs_dot = not dot and path
@@ -324,7 +324,7 @@ class Script(object):
scopes = resolve_import_paths(scopes)
# add keywords
scopes |= keywords.get_keywords(string=goto_path, pos=self.pos)
scopes |= keywords.keywords(string=goto_path, pos=self.pos)
d = set([api_classes.Definition(s) for s in scopes
if not isinstance(s, imports.ImportPath._GlobalNamespace)])

View File

@@ -4,6 +4,7 @@ import pydoc
import keyword
from jedi._compatibility import is_py3k
from jedi import parsing_representation as pr
from jedi import common
import builtin
@@ -19,7 +20,7 @@ else:
keys = keyword.kwlist + ['None', 'False', 'True']
def get_keywords(string='', pos=(0, 0), all=False):
def keywords(string='', pos=(0, 0), all=False):
if all:
return set([Keyword(k, pos) for k in keys])
if string in keys:
@@ -27,6 +28,15 @@ def get_keywords(string='', pos=(0, 0), all=False):
return set()
def keyword_names(*args, **kwargs):
kwds = []
for k in keywords(*args, **kwargs):
start = k.start_pos
end = start[0], start[1] + len(k.name)
kwds.append(pr.Name(k.parent, [(k.name, start)], start, end, k))
return kwds
def get_operator(string, pos):
return Keyword(string, pos)

View File

@@ -100,10 +100,6 @@ import os
import re
from ast import literal_eval
if __name__ == '__main__':
import sys
sys.path.insert(0, '..')
import jedi
from jedi._compatibility import unicode, reduce, StringIO, is_py3k
@@ -289,6 +285,7 @@ if __name__ == '__main__':
t_start = time.time()
# Sorry I didn't use argparse here. It's because argparse is not in the
# stdlib in 2.5.
import sys
args = sys.argv[1:]
try:
i = args.index('--thirdparty')

View File

@@ -81,6 +81,11 @@ class TestRegression(TestBase):
r = list(self.goto_definitions("asfdasfd", (1, 1)))
assert len(r) == 0
k = self.completions("fro")[0]
imp_start = '\nThe ``import'
assert k.raw_doc.startswith(imp_start)
assert k.doc.startswith(imp_start)
def test_operator_doc(self):
r = list(self.goto_definitions("a == b", (1, 3)))
assert len(r) == 1
@@ -447,7 +452,6 @@ class TestRegression(TestBase):
class TestDocstring(TestBase):
def test_function_doc(self):
defs = self.goto_definitions("""
def func():
@@ -538,7 +542,6 @@ class TestSpeed(TestBase):
class TestInterpreterAPI(unittest.TestCase):
def check_interpreter_complete(self, source, namespace, completions,
**kwds):
script = api.Interpreter(source, [namespace], **kwds)