def test_inline_tag(): @inline def func(x): return x assert get_inline_tag(func)
def handle_Call(state, node, prepend, **_): gen_sym = state.gen_sym constants = state.constants evaluated, fn = try_peval_expression(node.func, constants) if not evaluated or not get_inline_tag(fn): return state, node return_name, gen_sym = gen_sym('return') inlined_body, gen_sym, constants = _inline(node, gen_sym, return_name, constants) prepend(inlined_body) new_state = state.update(gen_sym=gen_sym, constants=constants) return new_state, ast.Name(id=return_name, ctx=ast.Load())
def test_inline_prohibit_closure(): @inline def no_closure(x): return x assert get_inline_tag(no_closure) a = 1 def with_closure(x): return x + a with pytest.raises(ValueError): with_closure = inline(with_closure)