From dfea9a6a26b1c9c8961aff8b813b96afdbfe2abb Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 15 Apr 2025 18:09:33 +0200 Subject: [PATCH] Document visit method return type (#13831) --- stdlib/ast.pyi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 90c6d2ff0..1a3d3e97d 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1893,8 +1893,12 @@ if sys.version_info >= (3, 14): def compare(left: AST, right: AST, /, *, compare_attributes: bool = False) -> bool: ... class NodeVisitor: + # All visit methods below can be overwritten by subclasses and return an + # arbitrary value, which is passed to the caller. def visit(self, node: AST) -> Any: ... def generic_visit(self, node: AST) -> Any: ... + # The following visit methods are not defined on NodeVisitor, but can + # be implemented by subclasses and are called during a visit if defined. def visit_Module(self, node: Module) -> Any: ... def visit_Interactive(self, node: Interactive) -> Any: ... def visit_Expression(self, node: Expression) -> Any: ...