From 995707f3ade36fc9b333a02bf3631f68cb58bff7 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 5 Feb 2020 17:59:04 +0200 Subject: [PATCH] Run lint with pre-commit --- .github/workflows/lint.yml | 17 +++++++++++++++++ .pre-commit-config.yaml | 32 ++++++++++++++++++++++++++++++++ .travis.yml | 5 ++++- MANIFEST.in | 1 + tox.ini | 8 ++------ 5 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 576b88414..3cad8d417 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,6 +15,22 @@ jobs: steps: - uses: actions/checkout@v1 + - name: pip cache + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: lint-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + lint-pip- + + - name: pre-commit cache + uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: lint-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} + restore-keys: | + lint-pre-commit- + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: @@ -30,3 +46,4 @@ jobs: - name: Lint run: tox -e lint + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..e30453c3e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +repos: + - repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black + args: ["--target-version", "py35"] + # Only .py files, until https://github.com/psf/black/issues/402 resolved + files: \.py$ + types: [] + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.9 + hooks: + - id: flake8 + additional_dependencies: [flake8-2020, flake8-implicit-str-concat] + + - repo: https://github.com/timothycrosley/isort + rev: 4.3.21 + hooks: + - id: isort + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.5.1 + hooks: + - id: python-check-blanket-noqa + - id: rst-backticks + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.5.0 + hooks: + - id: check-merge-conflict + - id: check-yaml diff --git a/.travis.yml b/.travis.yml index 038bf0b76..e77102e44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,9 @@ dist: xenial language: python -cache: pip +cache: + pip: true + directories: + - $HOME/.cache/pre-commit notifications: irc: "chat.freenode.net#pil" diff --git a/MANIFEST.in b/MANIFEST.in index 47daf4a11..a5f726b04 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,6 +6,7 @@ include *.py include *.rst include *.sh include *.txt +include *.yaml include LICENSE include Makefile include tox.ini diff --git a/tox.ini b/tox.ini index cdfd05dde..9f310ca3a 100644 --- a/tox.ini +++ b/tox.ini @@ -24,13 +24,9 @@ deps = [testenv:lint] commands = - black --target-version py35 --check --diff . - flake8 --statistics --count - isort --check-only --diff + pre-commit run --all-files check-manifest deps = - black + pre-commit check-manifest - flake8 - isort skip_install = true