def AsyncFunctionDef(draw, statements) -> ast.AsyncFunctionDef: n = draw(name()) args = draw(arguments()) body = draw(lists(statements, min_size=1, max_size=3)) decorator_list = draw(lists(Name(), min_size=0, max_size=2)) returns = draw(none() | expression()) return ast.AsyncFunctionDef(n, args, body, decorator_list, returns)
def ExceptHandler(draw, statements) -> ast.ExceptHandler: t = draw(none() | Name()) n = None if t is not None: n = draw(name()) return ast.ExceptHandler(type=t, name=n, body=draw( lists(statements, min_size=1, max_size=3)))
def ClassDef(draw, statements) -> ast.ClassDef: n = draw(name()) bases = draw(lists(expression(), min_size=0, max_size=2)) keywords = draw(lists(keyword(), min_size=0, max_size=2)) assume(len({kw.arg for kw in keywords}) == len(keywords)) body = draw(lists(statements, min_size=1, max_size=3)) decorator_list = draw(lists(Name(), min_size=0, max_size=2)) return ast.ClassDef(name=n, bases=bases, keywords=keywords, body=body, decorator_list=decorator_list)
def AugAssign(draw): op = draw( sampled_from([ ast.Add(), ast.Sub(), ast.Mult(), ast.Div(), ast.FloorDiv(), ast.Mod(), ast.Pow(), ast.LShift(), ast.RShift(), ast.BitOr(), ast.BitXor(), ast.BitOr(), ast.BitAnd(), ast.MatMult() ])) return ast.AugAssign(target=draw(Name(ast.Store)), op=op, value=draw(expression()))
def AnnAssign(draw) -> ast.AnnAssign: target = draw(Name(ast.Store)) return ast.AnnAssign(target=target, annotation=draw(expression()), value=draw(expression()), simple=True)
def AsyncFor(draw, statements) -> ast.AsyncFor: target = draw(Name(ast.Store)) iter = draw(expression()) body = draw(lists(statements, min_size=1, max_size=3)) orelse = draw(lists(statements, min_size=1, max_size=3)) return ast.AsyncFor(target, iter, body, orelse)
def Assign(draw) -> ast.Assign: targets = draw(lists(Name(ast.Store), min_size=1, max_size=3)) return ast.Assign(targets=targets, value=draw(expression()))