From 8d8420bc5483be50a5e2738a88009c4b4b286ee8 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 8 May 2022 21:59:19 +0100 Subject: [PATCH] Fix bugs in `check_new_syntax.py` (#7808) --- tests/check_new_syntax.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/check_new_syntax.py b/tests/check_new_syntax.py index 41878fd2a906..6ccff7c10157 100755 --- a/tests/check_new_syntax.py +++ b/tests/check_new_syntax.py @@ -44,10 +44,12 @@ def visit_Subscript(self, node: ast.Subscript) -> None: class OldSyntaxFinder(ast.NodeVisitor): def visit_AnnAssign(self, node: ast.AnnAssign) -> None: AnnotationUnionFinder().visit(node.annotation) + self.generic_visit(node) def visit_arg(self, node: ast.arg) -> None: if node.annotation is not None: AnnotationUnionFinder().visit(node.annotation) + self.generic_visit(node) def _visit_function(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> None: if node.returns is not None: @@ -62,10 +64,12 @@ def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: def visit_Assign(self, node: ast.Assign) -> None: NonAnnotationUnionFinder().visit(node.value) + self.generic_visit(node) def visit_ClassDef(self, node: ast.ClassDef) -> None: for base in node.bases: NonAnnotationUnionFinder().visit(base) + self.generic_visit(node) class ObjectClassdefFinder(ast.NodeVisitor): def visit_ClassDef(self, node: ast.ClassDef) -> None: @@ -80,10 +84,12 @@ class TextFinder(ast.NodeVisitor): def visit_ImportFrom(self, node: ast.ImportFrom) -> None: if node.module == "typing" and any(thing.name == "Text" for thing in node.names): errors.append(f"{path}:{node.lineno}: Use `str` instead of `typing.Text` in a Python-3-only stub.") + self.generic_visit(node) def visit_Attribute(self, node: ast.Attribute) -> None: if isinstance(node.value, ast.Name) and node.value.id == "typing" and node.attr == "Text": errors.append(f"{path}:{node.lineno}: Use `str` instead of `typing.Text` in a Python-3-only stub.") + self.generic_visit(node) class IfFinder(ast.NodeVisitor): def visit_If(self, node: ast.If) -> None: