From 9d68669a84c6b73707d693bf30f0c912b9195150 Mon Sep 17 00:00:00 2001 From: Thomas Rausch Date: Mon, 23 Aug 2021 21:38:37 +0200 Subject: [PATCH 1/3] migrate .flake8 config to pyproject.toml through pflake8 --- .flake8 | 5 ----- .pre-commit-config.yaml | 3 +++ Makefile | 4 ++-- pyproject.toml | 7 +++++++ requirements.txt | 2 ++ 5 files changed, 14 insertions(+), 7 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 713a390e026ea..0000000000000 --- a/.flake8 +++ /dev/null @@ -1,5 +0,0 @@ -[flake8] -ignore = E203, E266, E501, W503, F403 -max-line-length = 110 -select = B,C,E,F,I,W,T4,B9 -exclude = node_modules,.venv*,dist,fixes,localstack/infra,localstack/node_modules, venv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b0bebc5b8bc0..e88e56492beea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,6 +22,9 @@ repos: rev: 3.9.2 hooks: - id: flake8 + entry: pflake8 + additional_dependencies: + - pyproject-flake8 - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.0.1 diff --git a/Makefile b/Makefile index 065c4b5f29dc0..17ef1b83a5b7c 100644 --- a/Makefile +++ b/Makefile @@ -185,10 +185,10 @@ reinstall-p3: ## Re-initialize the virtualenv with Python 3.x PIP_CMD=pip3 VENV_OPTS="-p '`which python3`'" make install lint: ## Run code linter to check code style - ($(VENV_RUN); python -m flake8 --show-source --config .flake8 . ) + ($(VENV_RUN); python -m pflake8 --show-source) lint-modified: ## Run code linter on modified files - ($(VENV_RUN); python -m flake8 --show-source --config .flake8 `git ls-files -m | grep '\.py$$' | xargs` ) + ($(VENV_RUN); python -m pflake8 --show-source `git ls-files -m | grep '\.py$$' | xargs` ) format: ($(VENV_RUN); python -m isort localstack tests; python -m black localstack tests ) diff --git a/pyproject.toml b/pyproject.toml index 9c33d590afccd..e86e9b8a241a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,3 +9,10 @@ extend_exclude = '(localstack/infra|localstack/node_modules)' profile = 'black' extend_skip = ['localstack/infra/', 'localstack/node_modules', 'bin'] line_length = 100 + +# call using pflake8 +[tool.flake8] +max-line-length = 110 +ignore = 'E203,E266,E501,W503,F403' +select = 'B,C,E,F,I,W,T4,B9' +exclude = 'node_modules,.venv*,dist,fixes,localstack/infra,localstack/node_modules, venv' diff --git a/requirements.txt b/requirements.txt index 51b802b1d9b67..57257aa9d62be 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,6 +35,8 @@ flake8>=3.6.0 #extended-lib flake8-black>=0.2.1 #extended-lib flake8-isort>=4.0.0 #extended-lib flake8-quotes>=0.11.0 #extended-lib +# enables flake8 configuration through pyproject.toml +pyproject-flake8 #extended-lib flask>=1.0.2 flask-cors>=3.0.3,<3.1.0 flask_swagger==0.2.12 From 44f5e8b06d9772f172706f71ee8ad884def3272a Mon Sep 17 00:00:00 2001 From: Thomas Rausch Date: Mon, 23 Aug 2021 21:50:32 +0200 Subject: [PATCH 2/3] migrate .coveragerc to pyproject.toml through toml extra --- .coveragerc | 7 ------- Makefile | 1 + bin/Dockerfile.base | 2 +- pyproject.toml | 10 ++++++++++ requirements.txt | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index b8188454fe4a6..0000000000000 --- a/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -relative_files = True -source = - localstack/ -omit = - localstack/infra/ - localstack/node_modules diff --git a/Makefile b/Makefile index 17ef1b83a5b7c..7548753ea64c2 100644 --- a/Makefile +++ b/Makefile @@ -148,6 +148,7 @@ test: test-coverage: ($(VENV_RUN); python -m coverage --version; \ + pip install "coverage[toml]>=5.5"; \ DEBUG=$(DEBUG) \ python -m coverage run $(COVERAGE_ARGS) -m \ pytest --durations=10 --log-cli-level=$(PYTEST_LOGLEVEL) -s $(PYTEST_ARGS) $(TEST_PATH)) diff --git a/bin/Dockerfile.base b/bin/Dockerfile.base index 5e1b33ee91e3a..cee5d08022f57 100644 --- a/bin/Dockerfile.base +++ b/bin/Dockerfile.base @@ -134,7 +134,7 @@ ADD localstack/dashboard/web/package.json localstack/dashboard/web/package.json RUN make install-web # install libs that require dependencies that are cleaned up below (e.g., gcc) -RUN (virtualenv .venv && source .venv/bin/activate && pip install 'cryptography<3.4' 'uamqp>=1.2.14' 'coverage>=5.5') +RUN (virtualenv .venv && source .venv/bin/activate && pip install 'cryptography<3.4' 'uamqp>=1.2.14' 'coverage[toml]>=5.5') # clean up (layers are later squashed into a single one) RUN rm -rf localstack/infra/elasticsearch/jdk/ diff --git a/pyproject.toml b/pyproject.toml index e86e9b8a241a5..bb0c8d351593d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,3 +16,13 @@ max-line-length = 110 ignore = 'E203,E266,E501,W503,F403' select = 'B,C,E,F,I,W,T4,B9' exclude = 'node_modules,.venv*,dist,fixes,localstack/infra,localstack/node_modules, venv' + +[tool.coverage.run] +relative_files = true +source = [ + "localstack/" +] +omit = [ + "localstack/infra/", + "localstack/node_modules" +] diff --git a/requirements.txt b/requirements.txt index 57257aa9d62be..f4999cb7e8488 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ black==21.6b0 #extended-lib cachetools>=3.1.1,<4.0.0 cbor2>=5.2.0 # coverage version should be synced with bin/Dockerfile.base -coverage>=5.5 +coverage[toml]>=5.5 coveralls==3.1.0 crontab>=0.22.6 # pin version to avoid Rust build issues: https://github.com/pyca/cryptography/issues/5771 From 6a90a0410f61a12b003ee4eee1dcc8f4f7b46acc Mon Sep 17 00:00:00 2001 From: Thomas Rausch Date: Mon, 23 Aug 2021 22:10:54 +0200 Subject: [PATCH 3/3] copy pyproject.toml into container --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 62c596af74780..b71b3b903c59e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -92,7 +92,7 @@ RUN ES_BASE_DIR=localstack/infra/elasticsearch; \ # run tests (to verify the build before pushing the image) ADD tests/ tests/ # add configuration files -ADD .coveragerc ./ +ADD pyproject.toml ./ # fixes a dependency issue with pytest and python3.7 https://github.com/pytest-dev/pytest/issues/5594 RUN pip uninstall -y argparse RUN pip uninstall -y dataclasses