Best Python code snippet using refurb_python
use_implicit_default.py
Source:use_implicit_default.py
...73 if default == Ellipsis:74 continue75 arg.initializer = default # type: ignore76ZippedArg = tuple[str | None, Expression, ArgKind]77def strip_caller_var_args(78 start: int, args: Iterator[ZippedArg]79) -> Iterator[ZippedArg]:80 for i, arg in enumerate(args):81 if i < start:82 continue83 if arg[2] == ArgKind.ARG_NAMED:84 yield arg85def check_func(caller: CallExpr, func: FuncDef, errors: list[Error]) -> None:86 args = list(zip(func.arg_names, func.arguments))87 if (88 isinstance(caller.callee, MemberExpr)89 and args90 and func.arg_names[0] in ("self", "cls")91 ):92 args.pop(0)93 lookup = dict(args)94 inject_stdlib_defaults(caller, [x[1] for x in args])95 caller_args = zip(caller.arg_names, caller.args, caller.arg_kinds)96 for i, arg in enumerate(args):97 if arg[1].kind == ArgKind.ARG_STAR:98 caller_args = strip_caller_var_args(i, caller_args) # type: ignore99 for i, (name, value, kind) in enumerate(caller_args):100 if i >= len(args):101 break102 if kind == ArgKind.ARG_NAMED:103 try:104 default = lookup[name].initializer105 except KeyError:106 continue107 elif kind == ArgKind.ARG_POS:108 default = args[i][1].initializer109 else:110 return # pragma: no cover111 if str(value) == str(default):112 errors.append(ErrorInfo(value.line, value.column))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!