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
+10 -6
View File
@@ -6,6 +6,16 @@ are ok in the master branch.
3. Add your name to AUTHORS.txt 3. Add your name to AUTHORS.txt
4. Push to your fork and submit a **pull request to the dev branch**. 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 If you have have previously filed a GitHub issue and want to contribute code
that addresses that issue, we prefer it if you use that addresses that issue, we prefer it if you use
[hub](https://github.com/github/hub) to convert your existing issue to a pull [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 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. 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.
+3 -3
View File
@@ -138,11 +138,11 @@ class Script(object):
if (u.relative_count > 0 or u.from_ns) and not re.search( if (u.relative_count > 0 or u.from_ns) and not re.search(
r'(,|from)\s*$|import\s+$', completion_line): r'(,|from)\s*$|import\s+$', completion_line):
completions += ((k, bs) for k completions += ((k, bs) for k
in keywords.get_keywords('import')) in keywords.keyword_names('import'))
if not path and not isinstance(u, pr.Import): if not path and not isinstance(u, pr.Import):
# add keywords # add keywords
completions += ((k, bs) for k in keywords.get_keywords( completions += ((k, bs) for k in keywords.keyword_names(
all=True)) all=True))
needs_dot = not dot and path needs_dot = not dot and path
@@ -324,7 +324,7 @@ class Script(object):
scopes = resolve_import_paths(scopes) scopes = resolve_import_paths(scopes)
# add keywords # 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 d = set([api_classes.Definition(s) for s in scopes
if not isinstance(s, imports.ImportPath._GlobalNamespace)]) if not isinstance(s, imports.ImportPath._GlobalNamespace)])
+11 -1
View File
@@ -4,6 +4,7 @@ import pydoc
import keyword import keyword
from jedi._compatibility import is_py3k from jedi._compatibility import is_py3k
from jedi import parsing_representation as pr
from jedi import common from jedi import common
import builtin import builtin
@@ -19,7 +20,7 @@ else:
keys = keyword.kwlist + ['None', 'False', 'True'] 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: if all:
return set([Keyword(k, pos) for k in keys]) return set([Keyword(k, pos) for k in keys])
if string in keys: if string in keys:
@@ -27,6 +28,15 @@ def get_keywords(string='', pos=(0, 0), all=False):
return set() 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): def get_operator(string, pos):
return Keyword(string, pos) return Keyword(string, pos)
+1 -4
View File
@@ -100,10 +100,6 @@ import os
import re import re
from ast import literal_eval from ast import literal_eval
if __name__ == '__main__':
import sys
sys.path.insert(0, '..')
import jedi import jedi
from jedi._compatibility import unicode, reduce, StringIO, is_py3k from jedi._compatibility import unicode, reduce, StringIO, is_py3k
@@ -289,6 +285,7 @@ if __name__ == '__main__':
t_start = time.time() t_start = time.time()
# Sorry I didn't use argparse here. It's because argparse is not in the # Sorry I didn't use argparse here. It's because argparse is not in the
# stdlib in 2.5. # stdlib in 2.5.
import sys
args = sys.argv[1:] args = sys.argv[1:]
try: try:
i = args.index('--thirdparty') i = args.index('--thirdparty')
+5 -2
View File
@@ -81,6 +81,11 @@ class TestRegression(TestBase):
r = list(self.goto_definitions("asfdasfd", (1, 1))) r = list(self.goto_definitions("asfdasfd", (1, 1)))
assert len(r) == 0 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): def test_operator_doc(self):
r = list(self.goto_definitions("a == b", (1, 3))) r = list(self.goto_definitions("a == b", (1, 3)))
assert len(r) == 1 assert len(r) == 1
@@ -447,7 +452,6 @@ class TestRegression(TestBase):
class TestDocstring(TestBase): class TestDocstring(TestBase):
def test_function_doc(self): def test_function_doc(self):
defs = self.goto_definitions(""" defs = self.goto_definitions("""
def func(): def func():
@@ -538,7 +542,6 @@ class TestSpeed(TestBase):
class TestInterpreterAPI(unittest.TestCase): class TestInterpreterAPI(unittest.TestCase):
def check_interpreter_complete(self, source, namespace, completions, def check_interpreter_complete(self, source, namespace, completions,
**kwds): **kwds):
script = api.Interpreter(source, [namespace], **kwds) script = api.Interpreter(source, [namespace], **kwds)