How to use is_builtin_container_type method in refurb

Best Python code snippet using refurb_python

no_len_cmp.py

Source:no_len_cmp.py Github

copy

Full Screen

...57 "builtins.frozenset",58 "builtins.str",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,...

Full Screen

Full Screen

type_util.py

Source:type_util.py Github

copy

Full Screen

...4def is_builtin_type(t: Type):5 return t in [ str, int, float, bool ]6def is_builtin_type_str(t: str):7 return t in [ 'str', 'int', 'float', 'bool' ]8def is_builtin_container_type(t: Type):9 return t in [ dict, set, list ]10def is_custom_type(t: Type):11 return not is_builtin_type(t) and not is_builtin_container_type(t)12def find_sym_from_full_name(s: str):13 syms = s.split(".")14 cur = globals()15 if len(syms) > 0:16 for s in syms:17 if isinstance(cur, dict):18 if s in cur:19 cur = cur[s]20 else:21 return None22 elif inspect.ismodule(cur):23 if hasattr(cur,s):24 cur = getattr(cur,s)25 else:...

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