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

Class CustomVisitor

Lib/test/test_asdl_parser.py:103–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102 def test_visitor(self):
103 class CustomVisitor(self.asdl.VisitorBase):
104 def __init__(self):
105 super().__init__()
106 self.names_with_seq = []
107
108 def visitModule(self, mod):
109 for dfn in mod.dfns:
110 self.visit(dfn)
111
112 def visitType(self, type):
113 self.visit(type.value)
114
115 def visitSum(self, sum):
116 for t in sum.types:
117 self.visit(t)
118
119 def visitConstructor(self, cons):
120 for f in cons.fields:
121 if f.seq:
122 self.names_with_seq.append(cons.name)
123
124 v = CustomVisitor()
125 v.visit(self.types['mod'])

Callers 1

test_visitorMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_visitorMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…