diff --git a/jedi/api/helpers.py b/jedi/api/helpers.py index 5f51d098..c95ea2dd 100644 --- a/jedi/api/helpers.py +++ b/jedi/api/helpers.py @@ -252,7 +252,10 @@ def get_call_signature_details(module, position): leaf = module.get_leaf_for_position(position, include_prefixes=True) if leaf.start_pos >= position: # Whitespace / comments after the leaf count towards the previous leaf. - leaf = leaf.get_previous_leaf() + try: + leaf = leaf.get_previous_leaf() + except IndexError: + return None if leaf == ')': if leaf.end_pos == position: diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index 5d09cdc9..9cba90f1 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -285,6 +285,7 @@ def test_no_signature(): X()(""") assert Script(s).call_signatures() == [] assert len(Script(s, column=2).call_signatures()) == 1 + assert Script('').call_signatures() == [] def test_dict_literal_in_incomplete_call():