Make sure the interpreter completions work better in Jupyter Notebook, fixes #1628

This commit is contained in:
Dave Halter
2020-07-12 22:20:06 +02:00
parent 396d7df314
commit 3ffe8475b8
2 changed files with 42 additions and 4 deletions

View File

@@ -683,6 +683,17 @@ def test_string_annotation(annotations, result, code):
assert [d.name for d in defs] == result
def test_name_not_inferred_properly():
"""
In IPython notebook it is typical that some parts of the code that is
provided was already executed. In that case if something is not properly
inferred, it should still infer from the variables it already knows.
"""
x = 1
d, = jedi.Interpreter('x = UNDEFINED; x', [locals()]).infer()
assert d.name == 'int'
def test_variable_reuse():
x = 1
d, = jedi.Interpreter('y = x\ny', [locals()]).infer()