MCPcopy Create free account
hub / github.com/apache/arrow / leave_ClassDef

Method leave_ClassDef

python/scripts/update_stub_docstrings.py:125–149  ·  view source on GitHub ↗
(self, original_node, updated_node)

Source from the content-addressed store, hash-verified

123 self.indentation += 1
124
125 def leave_ClassDef(self, original_node, updated_node):
126 name = self._full_name()
127 docstring = _get_docstring(name, self.module, self.indentation)
128
129 if docstring:
130 ellipsis_class = m.ClassDef(body=m.IndentedBlock(body=[
131 m.SimpleStatementLine(body=[
132 m.Expr(m.Ellipsis()), m.ZeroOrMore()]), m.ZeroOrMore()]))
133 func_class = m.ClassDef(body=m.IndentedBlock(
134 body=[m.FunctionDef(), m.ZeroOrMore()]))
135
136 if m.matches(updated_node, ellipsis_class):
137 updated_node = updated_node.deep_replace(
138 updated_node.body.body[0].body[0].value,
139 libcst.SimpleString(value=docstring))
140 elif m.matches(updated_node, func_class):
141 docstring_stmt = libcst.SimpleStatementLine(
142 body=[libcst.Expr(value=libcst.SimpleString(value=docstring))])
143 updated_node = updated_node.with_changes(
144 body=updated_node.body.with_changes(
145 body=[docstring_stmt] + list(updated_node.body.body)))
146
147 self.stack.pop()
148 self.indentation -= 1
149 return updated_node
150
151 def visit_FunctionDef(self, node):
152 self.stack.append(node.name.value)

Callers

nothing calls this directly

Calls 3

_full_nameMethod · 0.95
_get_docstringFunction · 0.85
listFunction · 0.85

Tested by

no test coverage detected