mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Use flake8-pyi 22.5.0, remove redundant parts of check_new_syntax (#7821)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user