From b2fe9ec2b86c72e935e755f3a202950b5ac897be Mon Sep 17 00:00:00 2001 From: Steffen Allner Date: Thu, 28 Jan 2021 10:35:09 +0100 Subject: [PATCH] Use pre-commit for linting. --- .github/workflows/lint.yml | 43 +++++++++++++++++++ .github/workflows/tests.yml | 1 - .pre-commit-config.yaml | 38 ++++++++++++++++ README.rst | 1 - js/jquery_datatables_plugins/__init__.py | 9 +++- .../test_jquery_datatables_plugins.rst | 1 - setup.cfg | 10 +++++ setup.py | 4 +- 8 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml create mode 100644 setup.cfg diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..05632a9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,43 @@ +name: Lint + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + type: [ "opened", "reopened", "synchronize" ] + +env: + FORCE_COLOR: 1 + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Cache + uses: actions/cache@v2 + with: + path: | + ~/.cache/pip + ~/.cache/pre-commit + key: + lint-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/.pre-commit-config.yaml') }} + restore-keys: | + lint-v1- + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install -U pip + python -m pip install pre-commit + - name: Lint + run: | + pre-commit run --all-files --show-diff-on-failure + env: + PRE_COMMIT_COLOR: always diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e4e658c..934315b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,6 @@ jobs: matrix: config: # [Python version, tox env] - - ["3.8", "flake8"] - ["2.7", "py27"] - ["3.6", "py36"] - ["3.7", "py37"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b805888 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,38 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: trailing-whitespace + exclude: resources/ + - id: end-of-file-fixer + exclude: resources/ + - id: fix-encoding-pragma + args: [--remove] + - id: check-yaml + - id: debug-statements + language_version: python3 + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 + language_version: python3 + additional_dependencies: [flake8-typing-imports==1.9.0] + - repo: https://github.com/pre-commit/mirrors-autopep8 + rev: v1.5.4 + hooks: + - id: autopep8 + - repo: https://github.com/timothycrosley/isort + rev: 5.7.0 + hooks: + - id: isort + args: [--filter-files] + files: \.py$ + - repo: local + hooks: + - id: rst + name: rst + entry: rst-lint --encoding utf-8 + files: .rst + language: python + additional_dependencies: [pygments, restructuredtext_lint] diff --git a/README.rst b/README.rst index 264545c..48e70ca 100644 --- a/README.rst +++ b/README.rst @@ -16,4 +16,3 @@ directory in ``js.jquery_datatables_plugins``) are published to some URL. It contains the following plugins: * DataTables Column Filter Add-on (http://jquery-datatables-column-filter.googlecode.com/svn/trunk/index.html) - diff --git a/js/jquery_datatables_plugins/__init__.py b/js/jquery_datatables_plugins/__init__.py index 4a29658..2766dd5 100644 --- a/js/jquery_datatables_plugins/__init__.py +++ b/js/jquery_datatables_plugins/__init__.py @@ -1,9 +1,16 @@ -from fanstatic import Library, Resource +from fanstatic import Library +from fanstatic import Resource from js.jquery_datatables import jquery_datatables_js + library = Library('jquery_datatables_plugins', 'resources') column_filter = Resource( library, 'columnfilter/media/js/jquery.dataTables.columnFilter.js', depends=[jquery_datatables_js], minified='columnfilter/media/js/jquery.dataTables.columnFilter.min.js') + + +__all__ = [ + 'column_filter', +] diff --git a/js/jquery_datatables_plugins/test_jquery_datatables_plugins.rst b/js/jquery_datatables_plugins/test_jquery_datatables_plugins.rst index 7d5161e..fc5a94f 100644 --- a/js/jquery_datatables_plugins/test_jquery_datatables_plugins.rst +++ b/js/jquery_datatables_plugins/test_jquery_datatables_plugins.rst @@ -7,4 +7,3 @@ these resources to be included on a page:: >>> import js.jquery_datatables_plugins as p >>> p.column_filter.need() - diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..8ed3068 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,10 @@ +[bdist_wheel] +universal = 1 + +[isort] +lines_between_sections = 0 +lines_after_imports = 2 +no_sections = True +from_first = True +lines_between_types = 0 +force_single_line = True diff --git a/setup.py b/setup.py index a4c433a..cc4c63d 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ -from setuptools import setup, find_packages +from setuptools import find_packages +from setuptools import setup import os + # The version of the wrapped library is the starting point for the # version number of the python package. # In bugfix releases of the python package, add a '-' suffix and an