From 13337e12bb2d93c314e46416e6606e054e808453 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 2 Mar 2021 18:34:46 -0600 Subject: [PATCH 1/2] pylint to precommit --- .github/workflows/build.yml | 4 ---- .pre-commit-config.yaml | 15 +++++++++++++++ .pylintrc | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d31bb47..cbac825 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,10 +50,6 @@ jobs: - name: Pre-commit hooks run: | pre-commit run --all-files - - name: PyLint - run: | - pylint $( find . -path './adafruit*.py' ) - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" )) - name: Run tests run: | cd tests/ && python -m unittest discover diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07f886c..354c761 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,3 +17,18 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace +- repo: https://github.com/pycqa/pylint + rev: pylint-2.7.1 + hooks: + - id: pylint + name: pylint (library code) + types: [python] + exclude: "^(docs/|examples/|setup.py$)" +- repo: local + hooks: + - id: pylint_examples + name: pylint (examples code) + description: Run pylint rules on "examples/*.py" files + entry: /usr/bin/env bash -c + args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] + language: system diff --git a/.pylintrc b/.pylintrc index 5ce165c..3b23eb9 100644 --- a/.pylintrc +++ b/.pylintrc @@ -250,7 +250,7 @@ ignore-comments=yes ignore-docstrings=yes # Ignore imports when computing similarities. -ignore-imports=no +ignore-imports=yes # Minimum lines number of a similarity. min-similarity-lines=4 From 28c6f5ef25d5784ae16851791195f38cbecadc43 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 8 Mar 2021 18:31:42 -0600 Subject: [PATCH 2/2] tests pylint pre-commit hook --- .pre-commit-config.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 354c761..cce4c7b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: - id: pylint name: pylint (library code) types: [python] - exclude: "^(docs/|examples/|setup.py$)" + exclude: "^(docs/|tests/|examples/|setup.py$)" - repo: local hooks: - id: pylint_examples @@ -32,3 +32,11 @@ repos: entry: /usr/bin/env bash -c args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] language: system +- repo: local + hooks: + - id: pylint_tests + name: pylint (tests code) + description: Run pylint rules on "tests/*.py" files + entry: /usr/bin/env bash -c + args: ['([[ ! -d "tests" ]] || for test in $(find . -path "./tests/*.py"); do pylint --disable=missing-docstring $test; done)'] + language: system