Use flake8-pyi 22.5.0, remove redundant parts of check_new_syntax (#7821)

This commit is contained in:
Alex Waygood
2022-05-10 17:34:41 +01:00
committed by GitHub
parent fed1f35c32
commit f8547a3f31
2 changed files with 1 additions and 25 deletions

View File

@@ -4,7 +4,7 @@ pytype==2022.4.26; platform_system != "Windows"
black==22.3.0
flake8==4.0.1
flake8-bugbear==21.11.29
flake8-pyi==22.4.1
flake8-pyi==22.5.0
# must match .pre-commit-config.yaml
isort==5.10.1
tomli==1.2.2

View File

@@ -71,26 +71,6 @@ def check_new_syntax(tree: ast.AST, path: Path, stub: str) -> list[str]:
NonAnnotationUnionFinder().visit(base)
self.generic_visit(node)
class ObjectClassdefFinder(ast.NodeVisitor):
def visit_ClassDef(self, node: ast.ClassDef) -> None:
if any(isinstance(base, ast.Name) and base.id == "object" for base in node.bases):
errors.append(
f"{path}:{node.lineno}: Do not inherit from `object` explicitly, "
f"as all classes implicitly inherit from `object` in Python 3"
)
self.generic_visit(node)
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:
if (
@@ -106,10 +86,6 @@ def check_new_syntax(tree: ast.AST, path: Path, stub: str) -> list[str]:
)
self.generic_visit(node)
ObjectClassdefFinder().visit(tree)
if path != Path("stdlib/typing_extensions.pyi"):
TextFinder().visit(tree)
OldSyntaxFinder().visit(tree)
IfFinder().visit(tree)
return errors