Update testing: add docs + lint jobs; use pre-commit for linting (#426)

* Move docs and lint to their own [3.8] build job for more parallelism

* No codecov for docs or lint

* Move isort into pre-commit

* Add some handy linters to pre-commit

* Add rst-backticks linter and fix the errors

* Add pyupgrade and add upgrades

* Test docs and lint on GitHub Actions

* Xenial is default
This commit is contained in:
Hugo van Kemenade
2019-11-10 21:09:18 +02:00
committed by GitHub
parent 626a062747
commit b539e96697
9 changed files with 93 additions and 26 deletions
+30
View File
@@ -0,0 +1,30 @@
name: Docs and lint
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
env:
- TOXENV: docs
- TOXENV: lint
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
- name: Tox
run: tox
env: ${{ matrix.env }}
+25
View File
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.1
hooks:
- id: pyupgrade
args: ["--py3-plus"]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
additional_dependencies: [toml]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.4.2
hooks:
- id: python-check-blanket-noqa
- id: rst-backticks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
+24 -7
View File
@@ -1,13 +1,30 @@
language: python
python:
- 3.6
- 3.7
- 3.8
cache: pip
dist: xenial
cache:
pip: true
directories:
- $HOME/.cache/pre-commit
matrix:
fast_finish: true
include:
- python: 3.8
env: TOXENV=docs
- python: 3.8
env: TOXENV=lint
- python: 3.8
- python: 3.7
- python: 3.6
install: travis_retry pip install tox-travis
script: tox
after_success: bash <(curl -s https://codecov.io/bash)
after_success:
- |
if [[ "$TOXENV" != "docs" && "$TOXENV" != "lint" ]]; then
bash <(curl -s https://codecov.io/bash)
fi
deploy:
provider: pypi
user: jazzband
+1 -1
View File
@@ -1,6 +1,6 @@
recursive-include docs *
recursive-include tests *
include pyproject.toml pytest.ini tox.ini .coveragerc *.md LICENSE AUTHORS
include pyproject.toml pytest.ini tox.ini .coveragerc .pre-commit-config.yaml *.md LICENSE AUTHORS
prune docs/_build
prune *.pyc
prune __pycache__
+2 -2
View File
@@ -162,7 +162,7 @@ make the format available.
.. admonition:: Binary Warning
The `xls` file format is binary, so make sure to write in binary mode::
The ``xls`` file format is binary, so make sure to write in binary mode::
with open('output.xls', 'wb') as f:
f.write(data.export('xls'))
@@ -177,7 +177,7 @@ make the format available.
.. admonition:: Binary Warning
The `xlsx` file format is binary, so make sure to write in binary mode::
The ``xlsx`` file format is binary, so make sure to write in binary mode::
with open('output.xlsx', 'wb') as f:
f.write(data.export('xlsx'))
+1 -1
View File
@@ -1,7 +1,7 @@
.. Tablib documentation master file, created by
sphinx-quickstart on Tue Oct 5 15:25:21 2010.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
contain the root ``toctree`` directive.
Tablib: Pythonic Tabular Datasets
=================================
+1 -1
View File
@@ -411,7 +411,7 @@ class Dataset:
fmt = registry.get_format(format)
if not hasattr(fmt, 'import_set'):
raise UnsupportedFormat('Format {0} cannot be imported.'.format(format))
raise UnsupportedFormat('Format {} cannot be imported.'.format(format))
if not import_set:
raise UnsupportedFormat('Format {} cannot be imported.'.format(format))
+1 -2
View File
@@ -103,8 +103,7 @@ class Registry:
self.register('rst', ReSTFormat())
def formats(self):
for frm in self._formats.values():
yield frm
yield from self._formats.values()
def get_format(self, key):
if key not in self._formats:
+8 -12
View File
@@ -2,15 +2,11 @@
usedevelop = true
minversion = 2.4
envlist =
py{35,36,37,38}-tests,
py37-{docs,lint}
docs
lint
py{35,36,37,38}
[testenv]
basepython =
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
deps =
tests: -rtests/requirements.txt
docs: sphinx
@@ -19,20 +15,20 @@ commands =
tests: pytest {posargs:tests}
docs: sphinx-build -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html
[testenv:py37-lint]
basepython = python3.7
[testenv:lint]
deps =
check-manifest
flake8
# flake8-black
isort
pre-commit
twine
check-manifest
commands =
# flake8 src/tablib tests/
isort --check-only --diff
pre-commit run --all-files
check-manifest -v
python setup.py sdist
twine check dist/*
skip_install = true
[flake8]
exclude =