Best Python code snippet using refurb_python
no_len_cmp.py
Source:no_len_cmp.py
...59 "Tuple",60}61def is_builtin_container_type(type: str) -> bool:62 return any(type.startswith(x) for x in CONTAINER_TYPES)63def is_builtin_container_like(node: Expression) -> bool:64 match node:65 case NameExpr(node=Var(type=ty)) if is_builtin_container_type(str(ty)):66 return True67 case CallExpr(68 callee=NameExpr(fullname=name)69 ) if is_builtin_container_type(name or ""):70 return True71 case DictExpr() | ListExpr() | StrExpr() | TupleExpr():72 return True73 return False74def is_len_call(node: CallExpr) -> bool:75 match node:76 case CallExpr(77 callee=NameExpr(fullname="builtins.len"),78 args=[arg],79 ) if is_builtin_container_like(arg):80 return True81 return False82IS_COMPARISON_TRUTHY: dict[tuple[str, int], bool] = {83 ("==", 0): False,84 ("<=", 0): False,85 (">", 0): True,86 ("!=", 0): True,87 (">=", 1): True,88}89class LenComparisonVisitor(TraverserVisitor):90 errors: list[Error]91 def __init__(self, errors: list[Error]) -> None:92 super().__init__()93 self.errors = errors...
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!!