MCPcopy Create free account
hub / github.com/dot-agent/nextpy / _remove_docstring

Method _remove_docstring

scripts/pyi_generator.py:401–418  ·  view source on GitHub ↗

Removes any docstring in place. Args: node: The node to remove the docstring from. Returns: The modified node.

(
        node: ast.Module | ast.ClassDef | ast.FunctionDef,
    )

Source from the content-addressed store, hash-verified

399
400 @staticmethod
401 def _remove_docstring(
402 node: ast.Module | ast.ClassDef | ast.FunctionDef,
403 ) -> ast.Module | ast.ClassDef | ast.FunctionDef:
404 """Removes any docstring in place.
405
406 Args:
407 node: The node to remove the docstring from.
408
409 Returns:
410 The modified node.
411 """
412 if (
413 node.body
414 and isinstance(node.body[0], ast.Expr)
415 and isinstance(node.body[0].value, ast.Constant)
416 ):
417 node.body.pop(0)
418 return node
419
420 def visit_Module(self, node: ast.Module) -> ast.Module:
421 """Visit a Module node and remove docstring from body.

Callers 2

visit_ModuleMethod · 0.95
visit_ClassDefMethod · 0.95

Calls 1

popMethod · 0.45

Tested by

no test coverage detected