How to use is_boolean_literal method in refurb

Best Python code snippet using refurb_python

no_unnecessary_cast.py

Source:no_unnecessary_cast.py Github

copy

Full Screen

...51 "builtins.list": (ListExpr, "x.copy()"),52 "builtins.str": (StrExpr, "x"),53 "builtins.tuple": (TupleExpr, "x"),54}55def is_boolean_literal(node: Expression) -> bool:56 return isinstance(node, NameExpr) and node.fullname in (57 "builtins.True",58 "builtins.False",59 )60def check(node: CallExpr, errors: list[Error]) -> None:61 match node:62 case CallExpr(63 callee=NameExpr(fullname=fullname, name=name),64 args=[arg],65 ) if fullname in FUNC_NAMES:66 node_type, msg = FUNC_NAMES[fullname]67 if type(arg) == node_type:68 pass69 elif is_boolean_literal(arg) and name == "bool":70 pass71 else:72 match arg:73 case NameExpr(node=Var(type=ty)) if (74 str(ty).startswith(fullname)75 or (str(ty).startswith("Tuple") and name == "tuple")76 ):77 pass78 case _:79 return80 errors.append(81 ErrorInfo(82 node.line,83 node.column,...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run refurb automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful