Browse Source

Introduce pre-commit to the dev process (#212)

pull/218/head
Brett Cannon 3 years ago committed by GitHub
parent
commit
688e33ed05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      .github/workflows/test.yml
  2. 37
      .pre-commit-config.yaml
  3. 2
      .travis.yml
  4. 2
      LICENSE.APACHE
  5. 1
      MANIFEST.in
  6. 2
      docs/Makefile
  7. 2
      docs/development/reviewing-patches.rst
  8. 44
      tox.ini

8
.github/workflows/test.yml

@ -6,7 +6,7 @@ jobs:
test:
name: Test Python ${{ matrix.python_version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
@ -15,17 +15,17 @@ jobs:
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
name: Install Python ${{ matrix.python_version }}
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r dev-requirements.txt
- name: Test coverage
run: |
python -m coverage run --source packaging/ -m pytest --strict

37
.pre-commit-config.yaml

@ -0,0 +1,37 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.720
hooks:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
args: []
- id: mypy
name: mypy for Python 2
exclude: '^(docs|tasks|tests)|setup\.py'
args: ['--py2']
- repo: https://github.com/psf/black
rev: 19.3b0
hooks:
- id: black
- repo: https://gitlab.com/PyCQA/flake8
rev: '3.7.8'
hooks:
- id: flake8
additional_dependencies: ['pep8-naming']
# Ignore all format-related checks as Black takes care of those.
args: ['--ignore', 'E2,W5', '--select', 'E,W,F,N']
- repo: https://github.com/mgedmin/check-manifest
rev: '0.39'
hooks:
- id: check-manifest

2
.travis.yml

@ -22,10 +22,8 @@ matrix:
- python: 3.8-dev
env: TOXENV=py
dist: xenial
- env: TOXENV=mypy
- env: TOXENV=lint
- env: TOXENV=docs
- env: TOXENV=packaging
allow_failures:
- python: 3.8-dev

2
LICENSE.APACHE

@ -174,4 +174,4 @@
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS

1
MANIFEST.in

@ -3,6 +3,7 @@ include LICENSE LICENSE.APACHE LICENSE.BSD
include .coveragerc
include .flake8
include .pre-commit-config.yaml
include tox.ini
recursive-include docs *

2
docs/Makefile

@ -150,4 +150,4 @@ linkcheck:
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
"results in $(BUILDDIR)/doctest/output.txt."

2
docs/development/reviewing-patches.rst

@ -34,4 +34,4 @@ These are small things that are not caught by the automated style checkers.
* Does a variable need a better name?
* Should this be a keyword argument?
.. _`excellent to one another`: https://speakerdeck.com/ohrite/better-code-review
.. _`excellent to one another`: https://speakerdeck.com/ohrite/better-code-review

44
tox.ini

@ -13,11 +13,20 @@ commands =
[testenv:pypy]
commands =
py.test --capture=no --strict {posargs}
pytest --capture=no --strict {posargs}
[testenv:pypy3]
commands =
py.test --capture=no --strict {posargs}
pytest --capture=no --strict {posargs}
[testenv:lint]
basepython=python3
deps =
pre-commit
readme_renderer
commands =
pre-commit run --all-files
python setup.py check --metadata --restructuredtext --strict
[testenv:docs]
basepython = python3
@ -28,34 +37,3 @@ commands =
sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
sphinx-build -W -b latex -d {envtmpdir}/doctrees docs docs/_build/latex
sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html
[testenv:mypy]
basepython = python3
deps =
mypy
commands =
mypy packaging
mypy packaging --py2
[testenv:lint]
basepython = python3
deps =
flake8
pep8-naming
black
commands =
flake8 .
black --check .
[testenv:packaging]
deps =
check-manifest
readme_renderer
commands =
check-manifest
python setup.py check --metadata --restructuredtext --strict
[flake8]
exclude = .tox,*.egg
select = E,W,F,N
ignore = W504

Loading…
Cancel
Save