From 01af039e1b6c00ba73cbd0903d7cbbe4763e8dcc Mon Sep 17 00:00:00 2001 From: phalberg Date: Tue, 24 Nov 2026 16:59:11 +0100 Subject: [PATCH 1/7] chore: remove 3.11 guards as they are redudant --- stubs/flake8-bugbear/bugbear.pyi | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index 29f0ad038a0e..d7766f19782b 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -1,6 +1,5 @@ import argparse import ast -import sys from collections.abc import Generator, Iterable, Sequence from logging import Logger from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol, overload @@ -120,12 +119,9 @@ class BugBearVisitor(ast.NodeVisitor): def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: ... def visit_FunctionDef(self, node: ast.FunctionDef) -> None: ... def visit_ClassDef(self, node: ast.ClassDef) -> None: ... - if sys.version_info >= (3, 11): - def visit_Try(self, node: ast.Try | ast.TryStar) -> None: ... - def visit_TryStar(self, node: ast.TryStar) -> None: ... - else: - def visit_Try(self, node: ast.Try) -> None: ... - def visit_TryStar(self, node: ast.Try) -> None: ... + def visit_Try(self, node: ast.Try | ast.TryStar) -> None: ... + def visit_TryStar(self, node: ast.TryStar) -> None: ... + def visit_Compare(self, node: ast.Compare) -> None: ... def visit_Raise(self, node: ast.Raise) -> None: ... @@ -142,10 +138,8 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b039(self, node: ast.Call) -> None: ... def check_for_b007(self, node: ast.For | ast.AsyncFor) -> None: ... def check_for_b011(self, node: ast.Assert) -> None: ... - if sys.version_info >= (3, 11): - def check_for_b012(self, node: ast.Try | ast.TryStar) -> None: ... - else: - def check_for_b012(self, node: ast.Try) -> None: ... + def check_for_b012(self, node: ast.Try | ast.TryStar) -> None: ... + def check_for_b013_b014_b029_b030(self, node: ast.ExceptHandler) -> list[str]: ... def check_for_b015(self, node: ast.Compare) -> None: ... @@ -181,10 +175,7 @@ class BugBearVisitor(ast.NodeVisitor): 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_b908(self, node: ast.With) -> None: ... - if sys.version_info >= (3, 11): - def check_for_b025(self, node: ast.Try | ast.TryStar) -> None: ... - else: - def check_for_b025(self, node: ast.Try) -> None: ... + def check_for_b025(self, node: ast.Try | ast.TryStar) -> None: ... def check_for_b905(self, node: ast.Call) -> None: ... def check_for_b912(self, node: ast.Call) -> None: ... @@ -199,10 +190,8 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b044(self, node: ast.Assert) -> None: ... def check_for_b045(self, node: ast.For | ast.AsyncFor) -> None: ... def check_for_b046(self, node: ast.Call) -> None: ... - if sys.version_info >= (3, 11): - def check_for_b047(self, node: ast.Try | ast.TryStar) -> None: ... - else: - def check_for_b047(self, node: ast.Try) -> None: ... + def check_for_b047(self, node: ast.Try | ast.TryStar) -> None: ... + def check_for_b049(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> None: ... def check_for_b909(self, node: ast.For) -> None: ... From b5a7bf76dfb048f61d88de2774e2a91e2ba132ca Mon Sep 17 00:00:00 2001 From: phalberg Date: Tue, 24 Nov 2026 17:11:09 +0100 Subject: [PATCH 2/7] chore: add check for b049 --- stubs/flake8-bugbear/bugbear.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index d7766f19782b..9a4f01baf843 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -192,7 +192,7 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b046(self, node: ast.Call) -> None: ... def check_for_b047(self, node: ast.Try | ast.TryStar) -> 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: ... From 71522ac10d10b78a61ac3518a3d931e7525bb3de Mon Sep 17 00:00:00 2001 From: phalberg Date: Tue, 24 Nov 2026 17:32:26 +0100 Subject: [PATCH 3/7] chore: add exceptions --- stubs/flake8-bugbear/bugbear.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index 9a4f01baf843..1100bb14c248 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -271,6 +271,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[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]] From b9b66af21016a82cb43eb913bc8702c6275f057a Mon Sep 17 00:00:00 2001 From: phalberg Date: Tue, 24 Nov 2026 17:34:36 +0100 Subject: [PATCH 4/7] chore: add AnnAssign --- stubs/flake8-bugbear/bugbear.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index 1100bb14c248..5747d2a1719c 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -208,6 +208,7 @@ class B909Checker(ast.NodeVisitor): mutations: dict[int, list[ast.Assign | ast.AugAssign | ast.Delete | ast.Call]] def __init__(self, name: str, key: str) -> 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: ... From 5edc24104d927034dcd11d5221ed450daf9f4b8c Mon Sep 17 00:00:00 2001 From: phalberg Date: Wed, 25 Nov 2026 14:30:55 +0100 Subject: [PATCH 5/7] chore: update types and configurations --- .../@tests/stubtest_allowlist.txt | 22 +----- stubs/flake8-bugbear/METADATA.toml | 3 +- stubs/flake8-bugbear/bugbear.pyi | 78 +++++++++---------- 3 files changed, 40 insertions(+), 63 deletions(-) diff --git a/stubs/flake8-bugbear/@tests/stubtest_allowlist.txt b/stubs/flake8-bugbear/@tests/stubtest_allowlist.txt index 206909ae98a0..cf340e322fd6 100644 --- a/stubs/flake8-bugbear/@tests/stubtest_allowlist.txt +++ b/stubs/flake8-bugbear/@tests/stubtest_allowlist.txt @@ -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__ diff --git a/stubs/flake8-bugbear/METADATA.toml b/stubs/flake8-bugbear/METADATA.toml index d4ddff22bbea..d2397d3ef2f5 100644 --- a/stubs/flake8-bugbear/METADATA.toml +++ b/stubs/flake8-bugbear/METADATA.toml @@ -1,2 +1,3 @@ -version = "26.10.27" +version = "26.11.22" +requires-python=">=3.11" upstream-repository = "https://github.com/PyCQA/flake8-bugbear" diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index 5747d2a1719c..aecd44154967 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -1,8 +1,9 @@ import argparse import ast -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 @@ -26,12 +27,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: ... @@ -41,14 +44,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 @@ -74,7 +78,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] @@ -86,7 +90,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] = ..., @@ -107,6 +111,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: ... @@ -121,13 +126,16 @@ class BugBearVisitor(ast.NodeVisitor): def visit_ClassDef(self, node: ast.ClassDef) -> None: ... def visit_Try(self, node: ast.Try | ast.TryStar) -> None: ... def visit_TryStar(self, node: ast.TryStar) -> None: ... - - 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: ... @@ -139,44 +147,33 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b007(self, node: ast.For | ast.AsyncFor) -> None: ... def check_for_b011(self, node: ast.Assert) -> None: ... def check_for_b012(self, node: ast.Try | ast.TryStar) -> None: ... - - 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 + 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.Name | ast.Attribute | ast.Call) -> str: ... - @overload - @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: ... def check_for_b025(self, node: ast.Try | ast.TryStar) -> None: ... - def check_for_b905(self, node: ast.Call) -> None: ... def check_for_b912(self, node: ast.Call) -> None: ... def check_for_b913(self, node: ast.For) -> None: ... @@ -191,29 +188,29 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b045(self, node: ast.For | ast.AsyncFor) -> None: ... def check_for_b046(self, node: ast.Call) -> None: ... def check_for_b047(self, node: ast.Try | ast.TryStar) -> 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]] @@ -247,10 +244,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: ... @@ -272,7 +268,7 @@ 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[tuple[str, 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]] From bcc4f231ab2077b7c15be5db10e6d951fe643014 Mon Sep 17 00:00:00 2001 From: phalberg Date: Wed, 25 Nov 2026 14:53:02 +0100 Subject: [PATCH 6/7] Revert "chore: remove 3.11 guards as they are redudant" This reverts commit 01af039e1b6c00ba73cbd0903d7cbbe4763e8dcc. --- stubs/flake8-bugbear/bugbear.pyi | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index aecd44154967..55d29c76453f 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -1,6 +1,7 @@ import argparse import ast import tokenize +import sys from collections.abc import Iterable, Iterator from logging import Logger from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol @@ -124,8 +125,13 @@ class BugBearVisitor(ast.NodeVisitor): def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: ... def visit_FunctionDef(self, node: ast.FunctionDef) -> None: ... def visit_ClassDef(self, node: ast.ClassDef) -> None: ... - def visit_Try(self, node: ast.Try | ast.TryStar) -> None: ... - def visit_TryStar(self, node: ast.TryStar) -> None: ... + if sys.version_info >= (3, 11): + def visit_Try(self, node: ast.Try | ast.TryStar) -> None: ... + def visit_TryStar(self, node: ast.TryStar) -> None: ... + else: + def visit_Try(self, node: ast.Try) -> None: ... + def visit_TryStar(self, node: ast.Try) -> None: ... + def visit_Compare(self, node: ast.Compare) -> None: ... def visit_Raise(self, node: ast.Raise) -> None: ... def visit_With(self, node: ast.With) -> None: ... @@ -146,7 +152,11 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b039(self, node: ast.Call) -> None: ... def check_for_b007(self, node: ast.For | ast.AsyncFor) -> None: ... def check_for_b011(self, node: ast.Assert) -> None: ... - def check_for_b012(self, node: ast.Try | ast.TryStar) -> None: ... + if sys.version_info >= (3, 11): + def check_for_b012(self, node: ast.Try | ast.TryStar) -> None: ... + else: + def check_for_b012(self, node: ast.Try) -> None: ... + 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: ... @@ -173,7 +183,11 @@ class BugBearVisitor(ast.NodeVisitor): 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: ... - def check_for_b025(self, node: ast.Try | ast.TryStar) -> None: ... + if sys.version_info >= (3, 11): + def check_for_b025(self, node: ast.Try | ast.TryStar) -> None: ... + else: + def check_for_b025(self, node: ast.Try) -> None: ... + def check_for_b905(self, node: ast.Call) -> None: ... def check_for_b912(self, node: ast.Call) -> None: ... def check_for_b913(self, node: ast.For) -> None: ... @@ -187,7 +201,10 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b044(self, node: ast.Assert) -> None: ... def check_for_b045(self, node: ast.For | ast.AsyncFor) -> None: ... def check_for_b046(self, node: ast.Call) -> None: ... - def check_for_b047(self, node: ast.Try | ast.TryStar) -> None: ... + if sys.version_info >= (3, 11): + def check_for_b047(self, node: ast.Try | ast.TryStar) -> None: ... + 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: ... From f1ff18b058d67928750005f9d7fc4a35cee2ad41 Mon Sep 17 00:00:00 2001 From: phalberg Date: Wed, 25 Nov 2026 14:53:58 +0100 Subject: [PATCH 7/7] chore: revert back 3.10 handling for ci --- stubs/flake8-bugbear/bugbear.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/flake8-bugbear/bugbear.pyi b/stubs/flake8-bugbear/bugbear.pyi index 55d29c76453f..730f77d58797 100644 --- a/stubs/flake8-bugbear/bugbear.pyi +++ b/stubs/flake8-bugbear/bugbear.pyi @@ -1,7 +1,7 @@ import argparse import ast -import tokenize import sys +import tokenize from collections.abc import Iterable, Iterator from logging import Logger from typing import Any, ClassVar, Final, Literal, NamedTuple, Protocol @@ -205,6 +205,7 @@ class BugBearVisitor(ast.NodeVisitor): def check_for_b047(self, node: ast.Try | ast.TryStar) -> None: ... 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: ...