Skip to content

[flake8-simplify] Complete stubs #14259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions stubs/flake8-simplify/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
version = "0.21.*"
upstream_repository = "https://github.com/MartinThoma/flake8-simplify"
partial_stub = true

[tool.stubtest]
ignore_missing_stub = true
21 changes: 21 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
3 changes: 3 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/constants.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BOOL_CONST_TYPES: tuple[type, ...]
AST_CONST_TYPES: tuple[type, ...]
STR_TYPES: tuple[type, ...]
Empty file.
6 changes: 6 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_assign.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
8 changes: 8 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_bool_op.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
13 changes: 13 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_call.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
3 changes: 3 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_classdef.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ast

def get_sim120(node: ast.ClassDef) -> list[tuple[int, int, str]]: ...
4 changes: 4 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_compare.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
3 changes: 3 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_expr.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ast

def get_sim112(node: ast.Expr) -> list[tuple[int, int, str]]: ...
7 changes: 7 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_for.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
11 changes: 11 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_if.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
5 changes: 5 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_ifexp.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
3 changes: 3 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_subscript.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ast

def get_sim907(node: ast.Subscript) -> list[tuple[int, int, str]]: ...
4 changes: 4 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_try.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
8 changes: 8 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_unary_op.pyi
Original file line number Diff line number Diff line change
@@ -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]]: ...
3 changes: 3 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/rules/ast_with.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ast

def get_sim117(node: ast.With) -> list[tuple[int, int, str]]: ...
37 changes: 37 additions & 0 deletions stubs/flake8-simplify/flake8_simplify/utils.pyi
Original file line number Diff line number Diff line change
@@ -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: ...