From c7241068e84c06e5342cf34c2d89eb262c8f534f Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 2 Jan 2017 19:39:48 +0100 Subject: [PATCH] Fix an issue with call signatures in empty files. --- jedi/api/helpers.py | 5 ++++- test/test_api/test_call_signatures.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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():