Commit e4471f15 authored by Linus Pithan's avatar Linus Pithan

typing helper only adds '()' if to callable in case no parameters (excluding kwargs) are required

parent 5b3920e1
......@@ -158,8 +158,20 @@ class TypingHelper(object):
try:
self.validator.validate(new_doc)
repl.default_buffer.insert_text("()")
return True
# check if any parameters that are not keyword-arguments
# are needed, if yes -> don't complete!
try:
if len(cs_plus_open_bracket[-1].params) > 0:
for p in cs_plus_open_bracket[-1].params:
assert p.defined_names() != []
repl.default_buffer.insert_text("()")
return True
except AssertionError:
pass
except ValidationError:
pass
return False
......@@ -122,6 +122,24 @@ def test_shell_function_with_return_only(clean_gevent):
assert result == ""
def test_shell_callable_with_args(clean_gevent):
clean_gevent["end-check"] = False
result, cli, _ = _feed_cli_with_input("sum\r")
assert result == "sum"
def test_shell_callable_with_kwargs_only(clean_gevent):
clean_gevent["end-check"] = False
result, cli, _ = _feed_cli_with_input("property\r")
assert result == "property()"
def test_shell_callable_with_args_and_kwargs(clean_gevent):
clean_gevent["end-check"] = False
result, cli, _ = _feed_cli_with_input("compile\r")
assert result == "compile"
def test_shell_semicolon(clean_gevent):
clean_gevent["end-check"] = False
result, cli, _ = _feed_cli_with_input("print 1 2;print 1\r")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment