in utils/generate_inference_types.py [0:0]
def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> Optional[cst.ClassDef]:
"""Handle class definitions - remove if deprecated."""
docstring = self.get_docstring(original_node.body.body)
if self.is_deprecated(docstring):
return cst.RemoveFromParent()
new_body = []
statements = list(updated_node.body.body)
i = 0
while i < len(statements):
stmt = statements[i]
# Check if this is a field (AnnAssign)
if isinstance(stmt, cst.SimpleStatementLine) and isinstance(stmt.body[0], cst.AnnAssign):
# Look ahead for docstring
next_docstring = None
if i + 1 < len(statements):
next_docstring = self.get_docstring([statements[i + 1]])
if self.is_deprecated(next_docstring):
i += 2 # Skip both the field and its docstring
continue
new_body.append(stmt)
i += 1
if not new_body:
return cst.RemoveFromParent()
return updated_node.with_changes(body=updated_node.body.with_changes(body=new_body))