diff --git a/jedi/evaluate/compiled/mixed.py b/jedi/evaluate/compiled/mixed.py index da801c32..d289ed50 100644 --- a/jedi/evaluate/compiled/mixed.py +++ b/jedi/evaluate/compiled/mixed.py @@ -202,6 +202,8 @@ def _create(evaluator, access_handle, parent_context, *args): ) result = _find_syntax_node_name(evaluator, access_handle) + # TODO use stub contexts here. If we do that we probably have to care about + # generics from stuff like `[1]`. if result is None: return compiled_object diff --git a/test/test_api/test_interpreter.py b/test/test_api/test_interpreter.py index e39dd299..41b6e6c2 100644 --- a/test/test_api/test_interpreter.py +++ b/test/test_api/test_interpreter.py @@ -368,3 +368,28 @@ def test_sys_path_docstring(): # Was an issue in #1298 import jedi s = jedi.Interpreter("from sys import path\npath", line=2, column=4, namespaces=[locals()]) s.completions()[0].docstring() + + +@pytest.mark.parametrize( + 'code, completions', [ + ('x[0].uppe', ['upper']), + ('x[1337].uppe', ['upper']), + ('x[""].uppe', ['upper']), + ('x.appen', ['append']), + + ('y.add', ['add']), + ('y[0].', []), + ('list(y)[0].', []), # TODO use stubs properly to improve this. + + ('z[0].uppe', ['upper']), + ('z[0].append', ['append']), + ('z[1].uppe', ['upper']), + ('z[1].append', []), + ] +) +def test_simple_completions(code, completions): + x = [str] + y = {1} + z = {1: str, 2: list} + defs = jedi.Interpreter(code, [locals()]).completions() + assert [d.name for d in defs] == completions