From 506d02042061de165a0fdee4adc6d2abb433faac Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 11:30:45 +0200 Subject: [PATCH 1/9] GitHub Action to lint Python code --- .github/workflows/lint_python.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/lint_python.yml diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml new file mode 100644 index 00000000..24d2ae22 --- /dev/null +++ b/.github/workflows/lint_python.yml @@ -0,0 +1,25 @@ +name: lint_python +on: [pull_request, push] +jobs: + lint_python: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - run: pip install --upgrade pip wheel + - run: pip install bandit black codespell flake8 flake8-2020 flake8-bugbear + flake8-comprehensions flit isort mypy pytest pyupgrade safety + - run: bandit --recursive --skip B101,B324 . + - run: black --check --line-length 100 . || true + - run: codespell --ignore-words-list="fo,wil" --skip="*.svg" + - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,293 + --count --max-complexity=10 --max-line-length=100 --show-source --statistics + - run: isort --check-only --profile black . || true + - run: flit install + - run: mkdir --parents --verbose .mypy_cache + - run: mypy --ignore-missing-imports --install-types --non-interactive . || true + - run: pytest --doctest-modules . || pytest . || true + - run: shopt -s globstar && pyupgrade --py37-plus **/*.py || true + - run: pip install safety && safety check From 06d0362337cbd331996147fb0d170a69d8550365 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 11:33:22 +0200 Subject: [PATCH 2/9] Update lint_python.yml --- .github/workflows/lint_python.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 24d2ae22..073821de 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -1,5 +1,9 @@ name: lint_python -on: [pull_request, push] +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] jobs: lint_python: runs-on: ubuntu-latest @@ -13,7 +17,7 @@ jobs: flake8-comprehensions flit isort mypy pytest pyupgrade safety - run: bandit --recursive --skip B101,B324 . - run: black --check --line-length 100 . || true - - run: codespell --ignore-words-list="fo,wil" --skip="*.svg" + - run: codespell --ignore-words-list="fo,wil" --skip="*.po,*.svg" - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,293 --count --max-complexity=10 --max-line-length=100 --show-source --statistics - run: isort --check-only --profile black . || true From 3c64520e124099ae5cd57a0fbf8672c2efb4cbb6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 11:34:41 +0200 Subject: [PATCH 3/9] Fix typo discovered by codespell --- src/wily/operators/maintainability.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wily/operators/maintainability.py b/src/wily/operators/maintainability.py index 890a6a8c..58dca5e4 100644 --- a/src/wily/operators/maintainability.py +++ b/src/wily/operators/maintainability.py @@ -18,7 +18,7 @@ def mode(data): """ Return the modal value of a iterable with discrete values. - If there is more than 1 modal value, arbritrarily return the first top n. + If there is more than 1 modal value, arbitrarily return the first top n. """ c = Counter(data) mode, freq = c.most_common(1)[0] From cf4a001b591e3580671a8f0f8fe47a8d788a5469 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 11:38:45 +0200 Subject: [PATCH 4/9] flake8 --max-complexity=24 --max-line-length=218 --- .github/workflows/lint_python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 073821de..1d78791d 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -18,8 +18,8 @@ jobs: - run: bandit --recursive --skip B101,B324 . - run: black --check --line-length 100 . || true - run: codespell --ignore-words-list="fo,wil" --skip="*.po,*.svg" - - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,293 - --count --max-complexity=10 --max-line-length=100 --show-source --statistics + - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,W293,W503 + --count --max-complexity=24 --max-line-length=218 --show-source --statistics - run: isort --check-only --profile black . || true - run: flit install - run: mkdir --parents --verbose .mypy_cache From 131e9f69b92d09e136da96e5b3c8091c15e03f37 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 11:46:24 +0200 Subject: [PATCH 5/9] pip install mock --- .github/workflows/lint_python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 1d78791d..ece703f1 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -21,9 +21,9 @@ jobs: - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,W293,W503 --count --max-complexity=24 --max-line-length=218 --show-source --statistics - run: isort --check-only --profile black . || true - - run: flit install + - run: flit install && pip install mock - run: mkdir --parents --verbose .mypy_cache - run: mypy --ignore-missing-imports --install-types --non-interactive . || true - run: pytest --doctest-modules . || pytest . || true - run: shopt -s globstar && pyupgrade --py37-plus **/*.py || true - - run: pip install safety && safety check + - run: pip install safety && safety check # Must pip install to replace old version of `click` From 4a25e603bd3afc36cb47667214cc41389f2dcdba Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 11:49:43 +0200 Subject: [PATCH 6/9] Make pytest mandatory --- .github/workflows/lint_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index ece703f1..ab0d14b4 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -24,6 +24,6 @@ jobs: - run: flit install && pip install mock - run: mkdir --parents --verbose .mypy_cache - run: mypy --ignore-missing-imports --install-types --non-interactive . || true - - run: pytest --doctest-modules . || pytest . || true + - run: pytest . - run: shopt -s globstar && pyupgrade --py37-plus **/*.py || true - run: pip install safety && safety check # Must pip install to replace old version of `click` From c386d0c2963bf3176f3bc98ed1e8fe47314b6b81 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 17:22:45 +0200 Subject: [PATCH 7/9] pydocstyle --ignore=D301,D212,D203 wily --- .github/workflows/lint_python.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index ab0d14b4..4db397c7 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -14,13 +14,14 @@ jobs: python-version: 3.x - run: pip install --upgrade pip wheel - run: pip install bandit black codespell flake8 flake8-2020 flake8-bugbear - flake8-comprehensions flit isort mypy pytest pyupgrade safety + flake8-comprehensions flit isort mypy pydocstyle pytest pyupgrade safety - run: bandit --recursive --skip B101,B324 . - run: black --check --line-length 100 . || true - run: codespell --ignore-words-list="fo,wil" --skip="*.po,*.svg" - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,W293,W503 --count --max-complexity=24 --max-line-length=218 --show-source --statistics - run: isort --check-only --profile black . || true + - run: pydocstyle --ignore=D301,D212,D203 wily - run: flit install && pip install mock - run: mkdir --parents --verbose .mypy_cache - run: mypy --ignore-missing-imports --install-types --non-interactive . || true From 87fef3a72d47c654b834634bdf1c65786554bbb3 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 17:23:50 +0200 Subject: [PATCH 8/9] Update lint_python.yml --- .github/workflows/lint_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 4db397c7..f35836fd 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -21,7 +21,7 @@ jobs: - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,W293,W503 --count --max-complexity=24 --max-line-length=218 --show-source --statistics - run: isort --check-only --profile black . || true - - run: pydocstyle --ignore=D301,D212,D203 wily + - run: pydocstyle --ignore=D203,D212,D301 - run: flit install && pip install mock - run: mkdir --parents --verbose .mypy_cache - run: mypy --ignore-missing-imports --install-types --non-interactive . || true From 8b26d58035301be0f4342a97f0b194be16ceeb1c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 14 Jul 2022 17:26:46 +0200 Subject: [PATCH 9/9] Update lint_python.yml --- .github/workflows/lint_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index f35836fd..1419bc0a 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -21,7 +21,7 @@ jobs: - run: flake8 . --ignore C408,C416,E302,E402,E712,E741,F401,F541,F821,F841,R503,R504,W292,W293,W503 --count --max-complexity=24 --max-line-length=218 --show-source --statistics - run: isort --check-only --profile black . || true - - run: pydocstyle --ignore=D203,D212,D301 + - run: pydocstyle --ignore=D203,D212,D301 wily - run: flit install && pip install mock - run: mkdir --parents --verbose .mypy_cache - run: mypy --ignore-missing-imports --install-types --non-interactive . || true