From c82c368d4279081c04d17513ccee7e017c148d4e Mon Sep 17 00:00:00 2001 From: tyralla Date: Mon, 21 Oct 2024 09:45:15 +0200 Subject: [PATCH] Use `@deprecated` for those `visit` methods of class `NodeVisitor` that deal with classes that have already been marked with `@deprecated` and add `type: ignore[deprecated]` comments. --- stdlib/ast.pyi | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 3a43d62a3a60..e6be9038ba22 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -2023,11 +2023,19 @@ class NodeVisitor: def visit_AugLoad(self, node: AugLoad) -> Any: ... def visit_AugStore(self, node: AugStore) -> Any: ... def visit_Param(self, node: Param) -> Any: ... - def visit_Num(self, node: Num) -> Any: ... - def visit_Str(self, node: Str) -> Any: ... - def visit_Bytes(self, node: Bytes) -> Any: ... - def visit_NameConstant(self, node: NameConstant) -> Any: ... - def visit_Ellipsis(self, node: Ellipsis) -> Any: ... + + if sys.version_info < (3, 14): + @deprecated("Replaced by visit_Constant; removed in Python 3.14") + def visit_Num(self, node: Num) -> Any: ... # type: ignore[deprecated] + @deprecated("Replaced by visit_Constant; removed in Python 3.14") + def visit_Str(self, node: Str) -> Any: ... # type: ignore[deprecated] + @deprecated("Replaced by visit_Constant; removed in Python 3.14") + def visit_Bytes(self, node: Bytes) -> Any: ... # type: ignore[deprecated] + @deprecated("Replaced by visit_Constant; removed in Python 3.14") + def visit_NameConstant(self, node: NameConstant) -> Any: ... # type: ignore[deprecated] + @deprecated("Replaced by visit_Constant; removed in Python 3.14") + def visit_Ellipsis(self, node: Ellipsis) -> Any: ... # type: ignore[deprecated] + class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> AST: ...