MCPcopy Index your code
hub / github.com/python/cpython / DetectBadNodes

Class DetectBadNodes

Tools/clinic/libclinic/dsl_parser.py:973–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

971 # detect whether default is okay, via a denylist
972 # of disallowed ast nodes.
973 class DetectBadNodes(ast.NodeVisitor):
974 bad = False
975 def bad_node(self, node: ast.AST) -> None:
976 self.bad = True
977
978 # inline function call
979 visit_Call = bad_node
980 # inline if statement ("x = 3 if y else z")
981 visit_IfExp = bad_node
982
983 # comprehensions and generator expressions
984 visit_ListComp = visit_SetComp = bad_node
985 visit_DictComp = visit_GeneratorExp = bad_node
986
987 # literals for advanced types
988 visit_Dict = visit_Set = bad_node
989 visit_List = visit_Tuple = bad_node
990
991 # "starred": "a = [1, 2, 3]; *a"
992 visit_Starred = bad_node
993
994 denylist = DetectBadNodes()
995 denylist.visit(expr)

Callers 1

parse_parameterMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…