diff --git a/.github/workflows/docs-lint.yml b/.github/workflows/docs-lint.yml new file mode 100644 index 0000000..c0e240a --- /dev/null +++ b/.github/workflows/docs-lint.yml @@ -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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..026796a --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/.travis.yml b/.travis.yml index f9bf7bb..51d9452 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in index eaf41b5..ed238e9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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__ diff --git a/docs/formats.rst b/docs/formats.rst index 28ed5f9..489f57a 100644 --- a/docs/formats.rst +++ b/docs/formats.rst @@ -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')) diff --git a/docs/index.rst b/docs/index.rst index 44b2712..8bf4ac9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 ================================= diff --git a/src/tablib/core.py b/src/tablib/core.py index 9fcbebd..24a3471 100644 --- a/src/tablib/core.py +++ b/src/tablib/core.py @@ -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)) diff --git a/src/tablib/formats/__init__.py b/src/tablib/formats/__init__.py index c324484..9398607 100644 --- a/src/tablib/formats/__init__.py +++ b/src/tablib/formats/__init__.py @@ -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: diff --git a/tox.ini b/tox.ini index 78fd079..059f335 100644 --- a/tox.ini +++ b/tox.ini @@ -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 =