diff --git a/stubs/flake8-simplify/METADATA.toml b/stubs/flake8-simplify/METADATA.toml index 975ef0a56295..33165aaa6aac 100644 --- a/stubs/flake8-simplify/METADATA.toml +++ b/stubs/flake8-simplify/METADATA.toml @@ -1,6 +1,2 @@ version = "0.21.*" upstream_repository = "https://github.com/MartinThoma/flake8-simplify" -partial_stub = true - -[tool.stubtest] -ignore_missing_stub = true diff --git a/stubs/flake8-simplify/flake8_simplify/__init__.pyi b/stubs/flake8-simplify/flake8_simplify/__init__.pyi index c1831fa38365..5c2059f3ca1c 100644 --- a/stubs/flake8-simplify/flake8_simplify/__init__.pyi +++ b/stubs/flake8-simplify/flake8_simplify/__init__.pyi @@ -1,9 +1,30 @@ import ast +import logging from collections.abc import Generator from typing import Any, ClassVar +logger: logging.Logger + +class Visitor(ast.NodeVisitor): + def __init__(self) -> None: ... + def visit_Assign(self, node: ast.Assign) -> Any: ... + def visit_Call(self, node: ast.Call) -> Any: ... + def visit_With(self, node: ast.With) -> Any: ... + def visit_Expr(self, node: ast.Expr) -> None: ... + def visit_BoolOp(self, node: ast.BoolOp) -> None: ... + def visit_If(self, node: ast.If) -> None: ... + def visit_For(self, node: ast.For) -> None: ... + def visit_Subscript(self, node: ast.Subscript) -> None: ... + def visit_Try(self, node: ast.Try) -> None: ... + def visit_UnaryOp(self, node_v: ast.UnaryOp) -> None: ... + def visit_IfExp(self, node: ast.IfExp) -> None: ... + def visit_Compare(self, node: ast.Compare) -> None: ... + def visit_ClassDef(self, node: ast.ClassDef) -> None: ... + class Plugin: name: ClassVar[str] version: ClassVar[str] def __init__(self, tree: ast.AST) -> None: ... def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: ... + +def add_meta(root: ast.AST, level: int = 0) -> None: ... diff --git a/stubs/flake8-simplify/flake8_simplify/constants.pyi b/stubs/flake8-simplify/flake8_simplify/constants.pyi new file mode 100644 index 000000000000..66c47b6ad841 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/constants.pyi @@ -0,0 +1,3 @@ +BOOL_CONST_TYPES: tuple[type, ...] +AST_CONST_TYPES: tuple[type, ...] +STR_TYPES: tuple[type, ...] diff --git a/stubs/flake8-simplify/flake8_simplify/rules/__init__.pyi b/stubs/flake8-simplify/flake8_simplify/rules/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_assign.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_assign.pyi new file mode 100644 index 000000000000..019ac9f499a7 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_assign.pyi @@ -0,0 +1,6 @@ +import ast + +from flake8_simplify.utils import Assign + +def get_sim904(node: ast.Assign) -> list[tuple[int, int, str]]: ... +def get_sim909(node: Assign) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_bool_op.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_bool_op.pyi new file mode 100644 index 000000000000..d130dceae322 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_bool_op.pyi @@ -0,0 +1,8 @@ +import ast + +def get_sim101(node: ast.BoolOp) -> list[tuple[int, int, str]]: ... +def get_sim109(node: ast.BoolOp) -> list[tuple[int, int, str]]: ... +def get_sim220(node: ast.BoolOp) -> list[tuple[int, int, str]]: ... +def get_sim221(node: ast.BoolOp) -> list[tuple[int, int, str]]: ... +def get_sim222(node: ast.BoolOp) -> list[tuple[int, int, str]]: ... +def get_sim223(node: ast.BoolOp) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_call.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_call.pyi new file mode 100644 index 000000000000..d8b62cfa427d --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_call.pyi @@ -0,0 +1,13 @@ +import ast +import logging + +from flake8_simplify.utils import Call + +logger: logging.Logger + +def get_sim115(node: Call) -> list[tuple[int, int, str]]: ... +def get_sim901(node: ast.Call) -> list[tuple[int, int, str]]: ... +def get_sim905(node: ast.Call) -> list[tuple[int, int, str]]: ... +def get_sim906(node: ast.Call) -> list[tuple[int, int, str]]: ... +def get_sim910(node: Call) -> list[tuple[int, int, str]]: ... +def get_sim911(node: ast.AST) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_classdef.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_classdef.pyi new file mode 100644 index 000000000000..09dc22b3595f --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_classdef.pyi @@ -0,0 +1,3 @@ +import ast + +def get_sim120(node: ast.ClassDef) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_compare.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_compare.pyi new file mode 100644 index 000000000000..0a7b816a5e3c --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_compare.pyi @@ -0,0 +1,4 @@ +import ast + +def get_sim118(node: ast.Compare) -> list[tuple[int, int, str]]: ... +def get_sim300(node: ast.Compare) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_expr.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_expr.pyi new file mode 100644 index 000000000000..af53ac0309d8 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_expr.pyi @@ -0,0 +1,3 @@ +import ast + +def get_sim112(node: ast.Expr) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_for.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_for.pyi new file mode 100644 index 000000000000..235c7fd2b287 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_for.pyi @@ -0,0 +1,7 @@ +import ast + +from flake8_simplify.utils import For + +def get_sim104(node: ast.For) -> list[tuple[int, int, str]]: ... +def get_sim110_sim111(node: ast.For) -> list[tuple[int, int, str]]: ... +def get_sim113(node: For) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_if.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_if.pyi new file mode 100644 index 000000000000..65121cfcef51 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_if.pyi @@ -0,0 +1,11 @@ +import ast + +from flake8_simplify.utils import If + +def get_sim102(node: ast.If) -> list[tuple[int, int, str]]: ... +def get_sim103(node: ast.If) -> list[tuple[int, int, str]]: ... +def get_sim108(node: If) -> list[tuple[int, int, str]]: ... +def get_sim114(node: ast.If) -> list[tuple[int, int, str]]: ... +def get_sim116(node: ast.If) -> list[tuple[int, int, str]]: ... +def get_sim908(node: ast.If) -> list[tuple[int, int, str]]: ... +def get_sim401(node: ast.If) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_ifexp.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_ifexp.pyi new file mode 100644 index 000000000000..8a37a0c6a5ab --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_ifexp.pyi @@ -0,0 +1,5 @@ +import ast + +def get_sim210(node: ast.IfExp) -> list[tuple[int, int, str]]: ... +def get_sim211(node: ast.IfExp) -> list[tuple[int, int, str]]: ... +def get_sim212(node: ast.IfExp) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_subscript.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_subscript.pyi new file mode 100644 index 000000000000..eb2fa207b32b --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_subscript.pyi @@ -0,0 +1,3 @@ +import ast + +def get_sim907(node: ast.Subscript) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_try.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_try.pyi new file mode 100644 index 000000000000..9156100ebbe1 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_try.pyi @@ -0,0 +1,4 @@ +import ast + +def get_sim105(node: ast.Try) -> list[tuple[int, int, str]]: ... +def get_sim107(node: ast.Try) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_unary_op.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_unary_op.pyi new file mode 100644 index 000000000000..93603e0576f1 --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_unary_op.pyi @@ -0,0 +1,8 @@ +import ast + +from flake8_simplify.utils import UnaryOp + +def get_sim201(node: UnaryOp) -> list[tuple[int, int, str]]: ... +def get_sim202(node: UnaryOp) -> list[tuple[int, int, str]]: ... +def get_sim203(node: UnaryOp) -> list[tuple[int, int, str]]: ... +def get_sim208(node: ast.UnaryOp) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/rules/ast_with.pyi b/stubs/flake8-simplify/flake8_simplify/rules/ast_with.pyi new file mode 100644 index 000000000000..310080e7ec0d --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/rules/ast_with.pyi @@ -0,0 +1,3 @@ +import ast + +def get_sim117(node: ast.With) -> list[tuple[int, int, str]]: ... diff --git a/stubs/flake8-simplify/flake8_simplify/utils.pyi b/stubs/flake8-simplify/flake8_simplify/utils.pyi new file mode 100644 index 000000000000..3f4ea1c6524e --- /dev/null +++ b/stubs/flake8-simplify/flake8_simplify/utils.pyi @@ -0,0 +1,37 @@ +import ast +from _typeshed import Incomplete + +class UnaryOp(ast.UnaryOp): + parent: ast.Expr + def __init__(self, orig: ast.UnaryOp) -> None: ... + +class Call(ast.Call): + parent: ast.Expr + def __init__(self, orig: ast.Call) -> None: ... + +class If(ast.If): + parent: ast.Expr + def __init__(self, orig: ast.If) -> None: ... + +class For(ast.For): + parent: ast.AST + previous_sibling: Incomplete + def __init__(self, orig: ast.For) -> None: ... + +class Assign(ast.Assign): + parent: ast.AST + previous_sibling: Incomplete + def __init__(self, orig: ast.Assign) -> None: ... + +def to_source(node: ast.expr | ast.Expr | ast.withitem | ast.slice | ast.Assign | None) -> str: ... +def strip_parenthesis(string: str) -> str: ... +def strip_triple_quotes(string: str) -> str: ... +def use_double_quotes(string: str) -> str: ... +def is_body_same(body1: list[ast.stmt], body2: list[ast.stmt]) -> bool: ... +def is_stmt_equal(a: ast.stmt, b: ast.stmt) -> bool: ... +def get_if_body_pairs(node: ast.If) -> list[tuple[ast.expr, list[ast.stmt]]]: ... +def is_constant_increase(expr: ast.AugAssign) -> bool: ... +def is_exception_check(node: ast.If) -> bool: ... +def is_same_expression(a: ast.expr, b: ast.expr) -> bool: ... +def expression_uses_variable(expr: ast.expr, var: str) -> bool: ... +def body_contains_continue(stmts: list[ast.stmt]) -> bool: ...