Skip to content
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

Resolve new flake8 errors thanks to recent flake8-bugbear feature releases #2949

Closed
ichard26 opened this issue Mar 24, 2022 · 1 comment · Fixed by #2950
Closed

Resolve new flake8 errors thanks to recent flake8-bugbear feature releases #2949

ichard26 opened this issue Mar 24, 2022 · 1 comment · Fixed by #2950
Labels
C: maintenance Related to project maintenance, e.g. CI, testing, policy changes, releases good first issue Good for newcomers

Comments

@ichard26
Copy link
Collaborator

I recently accidentally cleared out all of my pre-commit hook installations and discovered using the latest version of everything nets us some new warnings:

❯ pre-commit run -a
black....................................................................Passed
Check pre-commit rev in example..........................................Passed
Check black version in the basics example................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

src/black/linegen.py:668:13: B020 Found for loop that reassigns the iterable it is iterating with each iterable value.
src/black/parsing.py:228:25: B020 Found for loop that reassigns the iterable it is iterating with each iterable value.

mypy.....................................................................Passed
prettier.................................................................Passed
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed

black/src/black/parsing.py

Lines 219 to 229 in 3800ebd

if isinstance(value, list):
for item in value:
# Ignore nested tuples within del statements, because we may insert
# parentheses and they change the AST.
if (
field == "targets"
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)

black/src/black/linegen.py

Lines 665 to 677 in 3800ebd

def dont_increase_indentation(split_func: Transformer) -> Transformer:
"""Normalize prefix of the first leaf in every line returned by `split_func`.
This is a decorator over relevant split functions.
"""
@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
return split_wrapper

@ichard26 ichard26 added good first issue Good for newcomers C: maintenance Related to project maintenance, e.g. CI, testing, policy changes, releases labels Mar 24, 2022
@ichard26
Copy link
Collaborator Author

Also visible here when the cache finally got evicted / expired: https://github.com/psf/black/runs/5668882528?check_suite_focus=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: maintenance Related to project maintenance, e.g. CI, testing, policy changes, releases good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant