From a18ee4018f855007bf4a23027a8d6478e56a36bf Mon Sep 17 00:00:00 2001 From: danieleades <33452915+danieleades@users.noreply.github.com> Date: Mon, 29 Nov 2021 02:20:52 +0000 Subject: [PATCH] add more flake8 lints (#2653) --- .pre-commit-config.yaml | 5 ++++- CHANGES.md | 1 + src/black/__init__.py | 2 +- src/black/output.py | 4 ++-- tests/optional.py | 2 +- tests/test_black.py | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3cd663..45810d2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,10 @@ repos: rev: 3.9.2 hooks: - id: flake8 - additional_dependencies: [flake8-bugbear] + additional_dependencies: + - flake8-bugbear + - flake8-comprehensions + - flake8-simplify - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.910 diff --git a/CHANGES.md b/CHANGES.md index d81c1fd..235919e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - Fixed Python 3.10 support on platforms without ProcessPoolExecutor (#2631) - Fixed `match` statements with open sequence subjects, like `match a, b:` (#2639) - Fixed assignment to environment variables in Jupyter Notebooks (#2642) +- Add `flake8-simplify` and `flake8-comprehensions` plugins (#2653) ## 21.11b1 diff --git a/src/black/__init__.py b/src/black/__init__.py index aa7970c..d99c48a 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -181,7 +181,7 @@ def validate_regex( @click.command( - context_settings=dict(help_option_names=["-h", "--help"]), + context_settings={"help_option_names": ["-h", "--help"]}, # While Click does set this field automatically using the docstring, mypyc # (annoyingly) strips 'em so we need to set it here too. help="The uncompromising code formatter.", diff --git a/src/black/output.py b/src/black/output.py index c85b253..f030d0a 100644 --- a/src/black/output.py +++ b/src/black/output.py @@ -59,8 +59,8 @@ def diff(a: str, b: str, a_name: str, b_name: str) -> str: """Return a unified diff string between strings `a` and `b`.""" import difflib - a_lines = [line for line in a.splitlines(keepends=True)] - b_lines = [line for line in b.splitlines(keepends=True)] + a_lines = a.splitlines(keepends=True) + b_lines = b.splitlines(keepends=True) diff_lines = [] for line in difflib.unified_diff( a_lines, b_lines, fromfile=a_name, tofile=b_name, n=5 diff --git a/tests/optional.py b/tests/optional.py index e12b94c..1cddeea 100644 --- a/tests/optional.py +++ b/tests/optional.py @@ -96,7 +96,7 @@ def pytest_collection_modifyitems(config: "Config", items: "List[Node]") -> None enabled_optional_markers = store[ENABLED_OPTIONAL_MARKERS] for item in items: - all_markers_on_test = set(m.name for m in item.iter_markers()) + all_markers_on_test = {m.name for m in item.iter_markers()} optional_markers_on_test = all_markers_on_test & all_possible_optional_markers if not optional_markers_on_test or ( optional_markers_on_test & enabled_optional_markers diff --git a/tests/test_black.py b/tests/test_black.py index 4267c61..51a2030 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -1755,7 +1755,7 @@ def assert_collected_sources( report=black.Report(), stdin_filename=stdin_filename, ) - assert sorted(list(collected)) == sorted(gs_expected) + assert sorted(collected) == sorted(gs_expected) class TestFileCollection: -- 2.39.5