def python_signature_complete(prefix, line, end, ctx, filter_func): """Completes a python function (or other callable) call by completing argument and keyword argument names. """ front = line[:end] if xt.is_balanced(front, '(', ')'): return set() funcname = xt.subexpr_before_unbalanced(front, '(', ')') val, _ctx = _safe_eval(funcname, ctx) if val is None: return set() try: sig = inspect.signature(val) except ValueError: return set() args = {p + '=' for p in sig.parameters if filter_func(p, prefix)} return args
def python_signature_complete(prefix, line, end, ctx, filter_func): """Completes a python function (or other callable) call by completing argument and keyword argument names. """ front = line[:end] if xt.is_balanced(front, '(', ')'): return set() funcname = xt.subexpr_before_unbalanced(front, '(', ')') val, _ctx = _safe_eval(funcname, ctx) if val is None and _ctx is None: return set() try: sig = inspect.signature(val) except ValueError: return set() args = {p + '=' for p in sig.parameters if filter_func(p, prefix)} return args
def test_is_not_balanced_parens(inp): obs = is_balanced(inp, "(", ")") assert not obs
def test_is_not_balanced_parens(inp): obs = is_balanced(inp, '(', ')') assert not obs