10 Commits

Author SHA1 Message Date
Dave Halter
86ae11eb43 Add a new release 0.13.2 2018-12-15 20:09:36 +01:00
Dave Halter
078595f8d7 Merge pull request #1262 from hoefling/pytest-marks
Use `pytest.param` when marking single parameters
2018-12-15 19:14:56 +01:00
Bet4
76417cc3c1 Fix environment cache regression (#1238)
The only remaining issue with this PR is that it does compare with executable instead of _start_executable (they don't need to be the same).
2018-12-15 18:37:28 +01:00
oleg.hoefling
70800a6dc2 bumped pytest dependency to 3.1.0 2018-12-07 18:22:29 +01:00
oleg.hoefling
4711b85b50 used pytest.param to comply with pytest>=4 2018-12-07 17:49:39 +01:00
micbou
368bf7e58a Improve docstring formatting 2018-11-26 00:26:34 +01:00
Jelte Fennema
3bdb941daa Add an exact_key_items method to DictComprehension fixes #1233 2018-10-14 17:08:44 +02:00
Dave Halter
bd1010bbd2 Create a new 0.13.1 release 2018-10-02 19:07:35 +02:00
Dave Halter
23b3327b1d Fixed completions of global vars and tensorflow slowness, fixes #1228, #1116 2018-10-02 15:28:51 +02:00
Dave Halter
075577d50c The changelog date was wrong 2018-10-02 15:25:31 +02:00
13 changed files with 81 additions and 16 deletions

View File

@@ -3,7 +3,17 @@
Changelog
---------
0.13.0 (2018-01-02)
0.13.2 (2018-12-15)
+++++++++++++++++++
- Fixed a bug that led to Jedi spawning a lot of subprocesses.
0.13.1 (2018-10-02)
+++++++++++++++++++
- Bugfixes, because tensorflow completions were still slow.
0.13.0 (2018-10-02)
+++++++++++++++++++
- A small release. Some bug fixes.

View File

@@ -36,7 +36,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.13.0'
__version__ = '0.13.2'
from jedi.api import Script, Interpreter, set_debug_function, \
preload_module, names

View File

@@ -178,17 +178,22 @@ class Script(object):
)
completions = completion.completions()
import_completions_count = len([
c for c in completions
if not c._name.tree_name
or c._name.tree_name.get_definition().type in ('import_name', 'import_from')
])
if import_completions_count > 10:
def iter_import_completions():
for c in completions:
tree_name = c._name.tree_name
if tree_name is None:
continue
definition = tree_name.get_definition()
if definition is not None \
and definition.type in ('import_name', 'import_from'):
yield c
if len(list(iter_import_completions())) > 10:
# For now disable completions if there's a lot of imports that
# might potentially be resolved. This is the case for tensorflow
# and has been fixed for it. This is obviously temporary until we
# have a better solution.
self._evaluator.infer_enabled = True
self._evaluator.infer_enabled = False
debug.speed('completions end')
return completions

View File

@@ -190,8 +190,9 @@ def get_default_environment():
def get_cached_default_environment():
var = os.environ.get('VIRTUAL_ENV')
environment = _get_cached_default_environment()
if environment.path != os.environ.get('VIRTUAL_ENV'):
if var and var != environment.path:
_get_cached_default_environment.clear_cache()
return _get_cached_default_environment()
return environment

View File

@@ -267,6 +267,11 @@ class DictComprehension(ComprehensionMixin, Sequence):
return ContextSet(FakeSequence(self.evaluator, u'list', lazy_contexts))
def exact_key_items(self):
# NOTE: A smarter thing can probably done here to achieve better
# completions, but at least like this jedi doesn't crash
return []
class GeneratorComprehension(ComprehensionMixin, GeneratorBase):
pass

View File

@@ -1,3 +1,4 @@
import re
import textwrap
from inspect import cleandoc
@@ -158,6 +159,7 @@ def get_call_signature(funcdef, width=72, call_string=None):
p = '(' + ''.join(param.get_code() for param in funcdef.get_params()).strip() + ')'
else:
p = funcdef.children[2].get_code()
p = re.sub(r'\s+', ' ', p)
if funcdef.annotation:
rtype = " ->" + funcdef.annotation.get_code()
else:
@@ -183,6 +185,8 @@ def get_doc_with_call_signature(scope_node):
doc = clean_scope_docstring(scope_node)
if call_signature is None:
return doc
if not doc:
return call_signature
return '%s\n\n%s' % (call_signature, doc)

View File

@@ -33,7 +33,7 @@ setup(name='jedi',
install_requires=install_requires,
extras_require={
'testing': [
'pytest>=2.3.5',
'pytest>=3.1.0',
# docopt for sith doctests
'docopt',
# coloroma for colored debug output

View File

@@ -154,6 +154,9 @@ def global_define():
#? int()
global_var_in_func
#? ['global_var_in_func']
global_var_in_f
def funct1():
# From issue #610
@@ -175,6 +178,7 @@ def init_global_var_predefined():
#? int() None
global_var_predefined
# -----------------
# within docstrs
# -----------------

View File

@@ -319,6 +319,7 @@ exe['c']
a = 'a'
exe2 = kwargs_func(**{a:3,
'b':4.0})
#? int()
exe2['a']
#? float()
@@ -326,6 +327,19 @@ exe2['b']
#? int() float()
exe2['c']
exe3 = kwargs_func(**{k: v for k, v in [(a, 3), ('b', 4.0)]})
# Should resolve to the same as 2 but jedi is not smart enough yet
# Here to make sure it doesn't result in crash though
#?
exe3['a']
#?
exe3['b']
#?
exe3['c']
# -----------------
# *args / ** kwargs
# -----------------

View File

@@ -138,18 +138,30 @@ set_t2.c
# python >= 3.5
d = {'a': 3}
dc = {v: 3 for v in ['a']}
#? dict()
{**d}
#? dict()
{**dc}
#? str()
{**d, "b": "b"}["b"]
#? str()
{**dc, "b": "b"}["b"]
# Should resolve to int() but jedi is not smart enough yet
# Here to make sure it doesn't result in crash though
#?
{**d}["a"]
# Should resolve to int() but jedi is not smart enough yet
# Here to make sure it doesn't result in crash though
#?
{**dc}["a"]
s = {1, 2, 3}
#? set()

View File

@@ -142,6 +142,16 @@ def test_docstring_keyword(Script):
assert 'assert' in completions[0].docstring()
def test_docstring_params_formatting(Script):
defs = Script("""
def func(param1,
param2,
param3):
pass
func""").goto_definitions()
assert defs[0].docstring() == 'func(param1, param2, param3)'
# ---- Numpy Style Tests ---
@pytest.mark.skipif(numpydoc_unavailable,

View File

@@ -87,10 +87,10 @@ def test_import_not_in_sys_path(Script):
("from flask.ext.", "bar"),
("from flask.ext.", "baz"),
("from flask.ext.", "moo"),
pytest.mark.xfail(("import flask.ext.foo; flask.ext.foo.", "Foo")),
pytest.mark.xfail(("import flask.ext.bar; flask.ext.bar.", "Foo")),
pytest.mark.xfail(("import flask.ext.baz; flask.ext.baz.", "Foo")),
pytest.mark.xfail(("import flask.ext.moo; flask.ext.moo.", "Foo")),
pytest.param("import flask.ext.foo; flask.ext.foo.", "Foo", marks=pytest.mark.xfail),
pytest.param("import flask.ext.bar; flask.ext.bar.", "Foo", marks=pytest.mark.xfail),
pytest.param("import flask.ext.baz; flask.ext.baz.", "Foo", marks=pytest.mark.xfail),
pytest.param("import flask.ext.moo; flask.ext.moo.", "Foo", marks=pytest.mark.xfail),
])
def test_flask_ext(Script, code, name):
"""flask.ext.foo is really imported from flaskext.foo or flask_foo.

View File

@@ -85,4 +85,4 @@ def test_get_call_signature(code, call_signature):
node = node.children[0]
assert parser_utils.get_call_signature(node) == call_signature
assert parser_utils.get_doc_with_call_signature(node) == (call_signature + '\n\n')
assert parser_utils.get_doc_with_call_signature(node) == call_signature