mirror of
https://github.com/davidhalter/jedi.git
synced 2026-08-13 23:30:59 +08:00
Merge branch 'dev' of github.com:davidhalter/jedi into dev
This commit is contained in:
@@ -43,6 +43,7 @@ bstaint (@bstaint)
|
|||||||
Mathias Rav (@Mortal) <rav@cs.au.dk>
|
Mathias Rav (@Mortal) <rav@cs.au.dk>
|
||||||
Daniel Fiterman (@dfit99) <fitermandaniel2@gmail.com>
|
Daniel Fiterman (@dfit99) <fitermandaniel2@gmail.com>
|
||||||
Simon Ruggier (@sruggier)
|
Simon Ruggier (@sruggier)
|
||||||
|
Élie Gouzien (@ElieGouzien)
|
||||||
|
|
||||||
|
|
||||||
Note: (@user) means a github user name.
|
Note: (@user) means a github user name.
|
||||||
|
|||||||
@@ -116,8 +116,21 @@ def _load_module(evaluator, path, python_object):
|
|||||||
return module
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
def source_findable(python_object):
|
||||||
|
"""Check if inspect.getfile has a chance to find the source."""
|
||||||
|
return (inspect.ismodule(python_object) or
|
||||||
|
inspect.isclass(python_object) or
|
||||||
|
inspect.ismethod(python_object) or
|
||||||
|
inspect.isfunction(python_object) or
|
||||||
|
inspect.istraceback(python_object) or
|
||||||
|
inspect.isframe(python_object) or
|
||||||
|
inspect.iscode(python_object))
|
||||||
|
|
||||||
|
|
||||||
def find_syntax_node_name(evaluator, python_object):
|
def find_syntax_node_name(evaluator, python_object):
|
||||||
try:
|
try:
|
||||||
|
if not source_findable(python_object):
|
||||||
|
raise TypeError # Prevents computation of `repr` within inspect.
|
||||||
path = inspect.getsourcefile(python_object)
|
path = inspect.getsourcefile(python_object)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# The type might not be known (e.g. class_with_dict.__weakref__)
|
# The type might not be known (e.g. class_with_dict.__weakref__)
|
||||||
|
|||||||
@@ -51,3 +51,19 @@ class TestSpeed(TestCase):
|
|||||||
with open('speed/precedence.py') as f:
|
with open('speed/precedence.py') as f:
|
||||||
line = len(f.read().splitlines())
|
line = len(f.read().splitlines())
|
||||||
assert jedi.Script(line=line, path='speed/precedence.py').goto_definitions()
|
assert jedi.Script(line=line, path='speed/precedence.py').goto_definitions()
|
||||||
|
|
||||||
|
@_check_speed(0.1)
|
||||||
|
def test_no_repr_computation(self):
|
||||||
|
"""
|
||||||
|
For Interpreter completion aquisition of sourcefile can trigger
|
||||||
|
unwanted computation of repr(). Exemple : big pandas data.
|
||||||
|
See issue #919.
|
||||||
|
"""
|
||||||
|
class SlowRepr():
|
||||||
|
"class to test what happens if __repr__ is very slow."
|
||||||
|
def some_method(self):
|
||||||
|
pass
|
||||||
|
def __repr__(self):
|
||||||
|
time.sleep(0.2)
|
||||||
|
test = SlowRepr()
|
||||||
|
jedi.Interpreter('test.som', [locals()]).completions()
|
||||||
|
|||||||
Reference in New Issue
Block a user