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

Method visit_FunctionDef

scripts/pyi_generator.py:506–531  ·  view source on GitHub ↗

Visit a FunctionDef node. Special handling for `.create` functions to add type hints for all props defined on the component class. Remove all private functions and blank out the function body of the remaining public functions. Args: node: The Fu

(self, node: ast.FunctionDef)

Source from the content-addressed store, hash-verified

504 return node
505
506 def visit_FunctionDef(self, node: ast.FunctionDef) -> Any:
507 """Visit a FunctionDef node.
508
509 Special handling for `.create` functions to add type hints for all props
510 defined on the component class.
511
512 Remove all private functions and blank out the function body of the
513 remaining public functions.
514
515 Args:
516 node: The FunctionDef node to visit.
517
518 Returns:
519 The modified FunctionDef node (or None).
520 """
521 if node.name == "create" and self.current_class in self.classes:
522 node = _generate_component_create_functiondef(
523 node, self.classes[self.current_class], self.type_hint_globals
524 )
525 else:
526 if node.name.startswith("_"):
527 return None # remove private methods
528
529 # Blank out the function body for public functions.
530 node.body = [ast.Expr(value=ast.Ellipsis())]
531 return node
532
533 def visit_Assign(self, node: ast.Assign) -> ast.Assign | None:
534 """Remove non-annotated assignment statements.

Callers

nothing calls this directly

Tested by

no test coverage detected