Fix an issue with call signatures in empty files.

This commit is contained in:
Dave Halter
2017-01-02 19:39:48 +01:00
parent 5d071ede8c
commit c7241068e8
2 changed files with 5 additions and 1 deletions

View File

@@ -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.
try:
leaf = leaf.get_previous_leaf()
except IndexError:
return None
if leaf == ')':
if leaf.end_pos == position:

View File

@@ -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():