From: Joe Young <80432516+jpy-git@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:14:21 +0000 (+0000) Subject: Resolve new flake8-bugbear errors (B020) (GH-2950) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/14d84ba2e96c5ca1351b8fe4d0d415cc148f4117?ds=inline;hp=14e5ce5412efa53438df0180e735b3834df3b579 Resolve new flake8-bugbear errors (B020) (GH-2950) Fixes a couple places where we were using the same variable name as we are iterating over. Co-authored-by: Jelle Zijlstra --- diff --git a/src/black/linegen.py b/src/black/linegen.py index cb605ee..9c85e76 100644 --- a/src/black/linegen.py +++ b/src/black/linegen.py @@ -670,9 +670,9 @@ def dont_increase_indentation(split_func: Transformer) -> Transformer: @wraps(split_func) def split_wrapper(line: Line, features: Collection[Feature] = ()) -> Iterator[Line]: - for line in split_func(line, features): - normalize_prefix(line.leaves[0], inside_brackets=True) - yield line + for split_line in split_func(line, features): + normalize_prefix(split_line.leaves[0], inside_brackets=True) + yield split_line return split_wrapper diff --git a/src/black/parsing.py b/src/black/parsing.py index db48ae4..1272656 100644 --- a/src/black/parsing.py +++ b/src/black/parsing.py @@ -225,8 +225,8 @@ def stringify_ast(node: Union[ast.AST, ast3.AST], depth: int = 0) -> Iterator[st and isinstance(node, (ast.Delete, ast3.Delete)) and isinstance(item, (ast.Tuple, ast3.Tuple)) ): - for item in item.elts: - yield from stringify_ast(item, depth + 2) + for elt in item.elts: + yield from stringify_ast(elt, depth + 2) elif isinstance(item, (ast.AST, ast3.AST)): yield from stringify_ast(item, depth + 2)