Skip to content

Commit

Permalink
Merge pull request #27 from dirn/pre-commit
Browse files Browse the repository at this point in the history
Use pre-commit for linting and fixing
  • Loading branch information
dirn committed Dec 3, 2020
2 parents 49543bf + 20322af commit 537fb7f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 47 deletions.
18 changes: 1 addition & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,7 @@ jobs:
with:
python-version: 3.6

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('test-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r test-requirements.txt
if: steps.cache.outputs.cache-hit != 'true'

- name: Run linters
run: |
tox -e lint
- uses: pre-commit/action@v2.0.0

manifest:
runs-on: ubuntu-latest
Expand Down
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
files: requirements\.txt$
- id: trailing-whitespace
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variables']
- repo: https://github.com/PyCQA/isort
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
language_version: python3.6
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-docstrings
- flake8-mypy
- pep8-naming
- pydocstyle
# This is required for Python 3.6.
- typing-extensions
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include LICENSE *.rst
exclude .editorconfig
exclude .editorconfig .pre-commit-config.yaml

# Tests
include tox.ini .coveragerc conftest.py *-requirements.txt
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pre-commit
pytest<3.3
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,3 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

28 changes: 0 additions & 28 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
envlist =
docs
manifest
lint
unit

[testenv:docs]
Expand All @@ -12,33 +11,6 @@ commands =
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
doc8 --allow-long-titles README.rst docs/ --ignore-path docs/_build/

[testenv:format]
# isort needs a full install to properly distinguish between first and
# third party packages. This also means Sphinx needs to be installed for
# doozer.contrib.sphinx.
deps =
black==20.8b1
isort==5.6.4
commands =
isort --recursive .
black .

[testenv:lint]
deps =
black==20.8b1
flake8==3.8.4
flake8-bugbear==20.11.1
flake8-comprehensions==3.3.0
flake8-docstrings==1.5.0
flake8-mypy==17.8.0
isort==5.6.4
pep8-naming==0.11.1
pydocstyle==5.1.1
typing-extensions
commands =
black --check .
flake8 .

[testenv:manifest]
deps =
check-manifest
Expand Down

0 comments on commit 537fb7f

Please sign in to comment.