From df536438073178da2940d6a36bdd9360fb7f4fc3 Mon Sep 17 00:00:00 2001 From: Stas Bekman Date: Tue, 22 Sep 2020 19:12:36 -0700 Subject: [PATCH] [code quality] fix confused flake8 (#7309) * fix confused flake We run `black --target-version py35 ...` but flake8 doesn't know that, so currently with py38 flake8 fails suggesting that black should have reformatted 63 files. Indeed if I run: ``` black --line-length 119 --target-version py38 examples templates tests src utils ``` it indeed reformats 63 files. The only solution I found is to create a black config file as explained at https://github.com/psf/black#configuration-format, which is what this PR adds. Now flake8 knows that py35 is the standard and no longer gets confused regardless of the user's python version. * adjust the other files that will now rely on black's config file --- .circleci/config.yml | 2 +- Makefile | 4 ++-- pyproject.toml | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 pyproject.toml diff --git a/.circleci/config.yml b/.circleci/config.yml index 5fc7bfad4a..7ed65de73c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -244,7 +244,7 @@ jobs: key: v0.3-code_quality-{{ checksum "setup.py" }} paths: - '~/.cache/pip' - - run: black --check --line-length 119 --target-version py35 examples templates tests src utils + - run: black --check examples templates tests src utils - run: isort --check-only examples templates tests src utils - run: flake8 examples templates tests src utils - run: python utils/check_copies.py diff --git a/Makefile b/Makefile index 83998723fc..6aef4b10f7 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Check that source code meets quality standards quality: - black --check --line-length 119 --target-version py35 examples templates tests src utils + black --check examples templates tests src utils isort --check-only examples templates tests src utils flake8 examples templates tests src utils python utils/check_copies.py @@ -12,7 +12,7 @@ quality: # Format source code automatically style: - black --line-length 119 --target-version py35 examples templates tests src utils + black examples templates tests src utils isort examples templates tests src utils # Make marked copies of snippets of codes conform to the original diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..291558c9a3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] +line-length = 119 +target-version = ['py35']