Skip to content
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
22 changes: 1 addition & 21 deletions stubs/flake8-bugbear/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
# Autogenerated methods using @attr.* decorators
# Autogenerated methods using @define decorators
.*\.__attrs_attrs__
.*\.__attrs_own_setattr__
.*\.__attrs_props__
bugbear.B040CaughtException.__match_args__
bugbear.B041VariableKeyType.__match_args__
bugbear.BugBearChecker.__ge__
bugbear.BugBearChecker.__gt__
bugbear.BugBearChecker.__le__
bugbear.BugBearChecker.__lt__
bugbear.BugBearChecker.__match_args__
bugbear.BugBearVisitor.__ge__
bugbear.BugBearVisitor.__gt__
bugbear.BugBearVisitor.__le__
bugbear.BugBearVisitor.__lt__
bugbear.BugBearVisitor.__match_args__
bugbear.NameFinder.__ge__
bugbear.NameFinder.__gt__
bugbear.NameFinder.__le__
bugbear.NameFinder.__lt__
bugbear.NameFinder.__match_args__
bugbear.NamedExprFinder.__ge__
bugbear.NamedExprFinder.__gt__
bugbear.NamedExprFinder.__le__
bugbear.NamedExprFinder.__lt__
bugbear.NamedExprFinder.__match_args__
bugbear.B020AttributeFinder.__ge__
bugbear.B020AttributeFinder.__gt__
bugbear.B020AttributeFinder.__le__
bugbear.B020AttributeFinder.__lt__
bugbear.B020AttributeFinder.__match_args__
# == Python 3.13
bugbear.B040CaughtException.__replace__
Expand Down
3 changes: 2 additions & 1 deletion stubs/flake8-bugbear/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
version = "26.10.27"
version = "26.11.22"
requires-python=">=3.11"
upstream-repository = "https://github.com/PyCQA/flake8-bugbear"
74 changes: 40 additions & 34 deletions stubs/flake8-bugbear/bugbear.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import argparse
import ast
import sys
from collections.abc import Generator, Iterable, Sequence
import tokenize
from collections.abc import Iterable, Iterator
from logging import Logger
from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, overload
from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol

__version__: Final[str]
LOG: Logger
Expand All @@ -27,12 +28,14 @@ class BugBearChecker:
version: ClassVar[str]
tree: ast.AST | None
filename: str
lines: Sequence[str] | None
lines: list[str] | None
max_line_length: int
visitor: ast.NodeVisitor
visitor: type[BugBearVisitor]
options: argparse.Namespace | None
file_tokens: list[tokenize.TokenInfo] | None
def run(self) -> Iterable[tuple[int, int, str, type[BugBearChecker]]]: ...
def gen_line_based_checks(self) -> Generator[error]: ...
def gen_line_based_checks(self) -> Iterator[error]: ...
def gen_token_based_checks(self) -> Iterator[error]: ...
@classmethod
def adapt_error(cls, e: error) -> tuple[int, int, str, type[BugBearChecker]]: ...
def load_file(self) -> None: ...
Expand All @@ -42,14 +45,15 @@ class BugBearChecker:
self,
tree: ast.AST | None = ...,
filename: str = ...,
lines: Sequence[str] | None = ...,
lines: list[str] | None = ...,
max_line_length: int = ...,
options: argparse.Namespace | None = ...,
file_tokens: list[tokenize.TokenInfo] | None = ...,
) -> None: ...
def should_warn(self, code: str) -> bool: ...

def names_from_assignments(assign_target: ast.expr) -> Generator[str]: ...
def children_in_scope(node: ast.AST) -> Generator[ast.AST]: ...
def names_from_assignments(assign_target: ast.expr) -> Iterator[str]: ...
def children_in_scope(node: ast.AST) -> Iterator[ast.AST]: ...

class ExceptBaseExceptionVisitor(ast.NodeVisitor):
root: ast.ExceptHandler
Expand All @@ -75,7 +79,7 @@ class AstPositionNode(Protocol):

class BugBearVisitor(ast.NodeVisitor):
filename: str
lines: Sequence[str] | None
lines: list[str]
b008_b039_extend_immutable_calls: set[str]
b902_classmethod_decorators: set[str]
node_window: list[ast.AST]
Expand All @@ -87,7 +91,7 @@ class BugBearVisitor(ast.NodeVisitor):
def __init__(
self,
filename: str,
lines: Sequence[str] | None,
lines: list[str],
b008_b039_extend_immutable_calls: set[str] = ...,
b902_classmethod_decorators: set[str] = ...,
node_window: list[ast.AST] = ...,
Expand All @@ -108,6 +112,7 @@ class BugBearVisitor(ast.NodeVisitor):
def visit_UAdd(self, node: ast.UAdd) -> None: ...
def visit_Call(self, node: ast.Call) -> None: ...
def visit_Module(self, node: ast.Module) -> None: ...
def visit_Name(self, node: ast.Name) -> None: ...
def visit_Assign(self, node: ast.Assign) -> None: ...
def visit_For(self, node: ast.For) -> None: ...
def visit_AsyncFor(self, node: ast.AsyncFor) -> None: ...
Expand All @@ -130,8 +135,13 @@ class BugBearVisitor(ast.NodeVisitor):
def visit_Compare(self, node: ast.Compare) -> None: ...
def visit_Raise(self, node: ast.Raise) -> None: ...
def visit_With(self, node: ast.With) -> None: ...
def visit_MatchAs(self, node: ast.MatchAs) -> None: ...
def visit_MatchMapping(self, node: ast.MatchMapping) -> None: ...
def visit_MatchStar(self, node: ast.MatchStar) -> None: ...
def visit_Global(self, node: ast.Global) -> None: ...
def visit_JoinedStr(self, node: ast.JoinedStr) -> None: ...
def visit_AnnAssign(self, node: ast.AnnAssign) -> None: ...
def visit_NamedExpr(self, node: ast.NamedExpr) -> None: ...
def visit_Import(self, node: ast.Import) -> None: ...
def visit_ImportFrom(self, node: ast.ImportFrom) -> None: ...
def visit_Set(self, node: ast.Set) -> None: ...
Expand All @@ -150,36 +160,28 @@ class BugBearVisitor(ast.NodeVisitor):
def check_for_b013_b014_b029_b030(self, node: ast.ExceptHandler) -> list[str]: ...
def check_for_b015(self, node: ast.Compare) -> None: ...
def check_for_b016(self, node: ast.Raise) -> None: ...
def check_for_b017(self, node: ast.With | ast.AsyncWith) -> None: ...
def check_for_b017(self, node: ast.With) -> None: ...
def check_for_b019(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> None: ...
def check_for_b020(self, node: ast.For | ast.AsyncFor | ast.comprehension) -> None: ...
def check_for_b020(self, node: ast.For | ast.AsyncFor) -> None: ...
def check_for_b023(
self, loop_node: ast.For | ast.AsyncFor | ast.While | ast.GeneratorExp | ast.SetComp | ast.ListComp | ast.DictComp
) -> None: ...
def check_for_b024_and_b027(self, node: ast.ClassDef) -> None: ...
def check_for_b026(self, call: ast.Call) -> None: ...
def check_for_b031(self, loop_node: ast.For | ast.AsyncFor) -> None: ...
def check_for_b031(self, loop_node: ast.For) -> None: ...
def check_for_b035(self, node: ast.DictComp) -> None: ...
def check_for_b040_add_note(self, node: ast.Attribute) -> bool: ...
def check_for_b040_usage(self, node: ast.expr | list[ast.expr] | list[ast.keyword] | None) -> None: ...
def check_for_b904(self, node: ast.Raise) -> None: ...
def walk_function_body(
self, node: ast.FunctionDef | ast.AsyncFunctionDef
) -> Generator[tuple[ast.FunctionDef | ast.AsyncFunctionDef, ast.stmt]]: ...
def check_for_b901(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> None: ...

@overload
@classmethod
def find_decorator_name(cls, d: ast.Name | ast.Attribute | ast.Call) -> str: ...
@overload
def walk_function_body(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> Iterator[tuple[ast.AST, ast.AST]]: ...
def check_for_b901(self, node: ast.FunctionDef) -> None: ...
@classmethod
def find_decorator_name(cls, d: ast.AST) -> str | None: ...

def find_decorator_name(cls, d: ast.expr) -> str | None: ...
def check_for_b902(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> None: ...
def check_for_b903(self, node: ast.ClassDef) -> None: ...
def check_for_b018(self, node: ast.AST) -> None: ...
def check_for_b021(self, node: ast.AsyncFunctionDef | ast.FunctionDef | ast.ClassDef | ast.Module) -> None: ...
def check_for_b022(self, node: ast.With | ast.AsyncWith) -> None: ...
def check_for_b021(self, node: ast.AsyncFunctionDef | ast.FunctionDef | ast.ClassDef) -> None: ...
def check_for_b022(self, node: ast.With) -> None: ...
def check_for_b908(self, node: ast.With) -> None: ...
if sys.version_info >= (3, 11):
def check_for_b025(self, node: ast.Try | ast.TryStar) -> None: ...
Expand All @@ -204,26 +206,29 @@ class BugBearVisitor(ast.NodeVisitor):
else:
def check_for_b047(self, node: ast.Try) -> None: ...

def check_for_b048(self, node: ast.Call) -> None: ...
def check_for_b049(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> None: ...
def check_for_b909(self, node: ast.For) -> None: ...
def check_for_b910(self, node: ast.Call) -> None: ...
def check_for_b911(self, node: ast.Call) -> None: ...

def compose_call_path(node: ast.expr) -> Generator[str]: ...
def compose_call_path(node: ast.expr) -> Iterator[str]: ...
def is_name(node: ast.expr, name: str) -> bool: ...

class B909Checker(ast.NodeVisitor):
MUTATING_FUNCTIONS: ClassVar[tuple[str, ...]]
name: str
key: str
mutations: dict[int, list[ast.Assign | ast.AugAssign | ast.Delete | ast.Call]]
def __init__(self, name: str, key: str) -> None: ...
key: str | None
check_subscript_assignments: bool
mutations: dict[int, list[ast.Assign | ast.AnnAssign | ast.AugAssign | ast.Delete | ast.Call]]
def __init__(self, name: str, key: str | None, *, check_subscript_assignments: bool = True) -> None: ...
def visit_Assign(self, node: ast.Assign) -> None: ...
def visit_AnnAssign(self, node: ast.AnnAssign) -> None: ...
def visit_AugAssign(self, node: ast.AugAssign) -> None: ...
def visit_Delete(self, node: ast.Delete) -> None: ...
def visit_Call(self, node: ast.Call) -> None: ...
def visit_If(self, node: ast.If) -> None: ...
def visit(self, node: ast.AST | list[ast.stmt]) -> Any: ...
def visit(self, node: ast.AST | list[ast.stmt]) -> ast.AST | list[ast.stmt] | None: ...

class NameFinder(ast.NodeVisitor):
names: dict[str, list[ast.Name]]
Expand Down Expand Up @@ -257,10 +262,9 @@ class FunctionDefDefaultsVisitor(ast.NodeVisitor):
b008_b039_extend_immutable_calls: set[str] | None = None,
imported_names: dict[str, str | None] | None = None,
) -> None: ...
def visit_mutable_literal_or_comprehension(
self, node: ast.List | ast.Dict | ast.Set | ast.ListComp | ast.DictComp | ast.SetComp
) -> None: ...
def visit_mutable_literal_or_comprehension(self, node: ast.expr) -> None: ...
def visit_Call(self, node: ast.Call) -> None: ...
def visit_NamedExpr(self, node: ast.NamedExpr) -> None: ...
def visit_Lambda(self, node: ast.Lambda) -> None: ...
def visit(self, node: ast.AST | list[ast.AST]) -> None: ...

Expand All @@ -282,6 +286,8 @@ B006_MUTABLE_LITERALS: Final[tuple[Literal["Dict"], Literal["List"], Literal["Se
B006_MUTABLE_COMPREHENSIONS: Final[tuple[Literal["ListComp"], Literal["DictComp"], Literal["SetComp"]]]
B006_MUTABLE_CALLS: Final[set[str]]
B008_IMMUTABLE_CALLS: Final[set[str]]
B040_HANDLED_EXCEPTION_CALLS: Final[set[tuple[str, str]]]
B040_HANDLED_EXCEPTION_NAMES: Final[set[str]]
B014_REDUNDANT_EXCEPTIONS: Final[dict[Literal["OSError", "ValueError"], set[str]]]
B019_CACHES: Final[set[str]]
B046_DICT_TYPES: Final[set[str]]
Expand Down
Loading