From 62a02ff7e40da01de8a9fa27e1c6d4606a85ac4f Mon Sep 17 00:00:00 2001 From: Mike Gerber Date: Fri, 13 Jun 2025 18:15:42 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=20=20Add=20pre-commit=20config=20+=20?= =?UTF-8?q?docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 35 +++++++++++++++++++++++++++++++++++ README-DEV.md | 7 +++++++ pyproject.toml | 39 +++++++++++++++++++++++++++++++++++++++ requirements-dev.txt | 4 ++++ 4 files changed, 85 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..10b7f5d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-json + - id: check-toml + - id: check-yaml + - id: check-added-large-files + - id: check-ast + +- repo: https://github.com/psf/black + rev: 25.1.0 + hooks: + - id: black + +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.11.13 + hooks: + - args: + - --fix + - --exit-non-zero-on-fix + id: ruff + +- repo: https://gitlab.com/vojko.pribudic.foss/pre-commit-update + rev: v0.7.0 + hooks: + - id: pre-commit-update + +- repo: https://github.com/dhatim/python-license-check + rev: 0.9.3 + hooks: + - id: liccheck + language: system diff --git a/README-DEV.md b/README-DEV.md index 33da234..0765657 100644 --- a/README-DEV.md +++ b/README-DEV.md @@ -15,3 +15,10 @@ To run a test with profiling: ``` pytest --profile-svg -k test_page_info ``` + +# How to use pre-commit + +This project optionally uses [pre-commit](https://pre-commit.com) to check commits. To use it: + +- Install pre-commit, e.g. `pip install -r requirements-dev.txt` +- Install the repo-local git hooks: `pre-commit install` diff --git a/pyproject.toml b/pyproject.toml index 69d7b80..400bc90 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,3 +44,42 @@ optional-dependencies.dev = {file = ["requirements-dev.txt"]} [tool.setuptools.packages.find] where = ["src"] + + +[tool.ruff.lint] +select = ["E", "F", "I"] + + +[tool.liccheck] +authorized_licenses = [ + "bsd", + "new bsd", + "bsd license", + "new bsd license", + "simplified bsd", + "apache", + "apache 2.0", + "apache software license", + "apache software", + "apache license 2.0", + "gnu lgpl", + "lgpl with exceptions or zpl", + "GNU Library or Lesser General Public License (LGPL)", + "GNU Lesser General Public License v3 (LGPLv3)", + "GNU Lesser General Public License v2 or later (LGPLv2+)", + "mit", + "mit license", + "mit-cmu", + "python software foundation", + "psf", + "psf-2.0", + "Historical Permission Notice and Disclaimer (HPND)", + "public domain", + 'The Unlicense (Unlicense)', + "isc", + "ISC License (ISCL)", + 'Mozilla Public License 2.0 (MPL 2.0)', +] +unauthorized_licenses = [ + "gpl v3", +] diff --git a/requirements-dev.txt b/requirements-dev.txt index e63c022..4e1b64f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,3 +7,7 @@ mypy types-lxml types-tqdm pandas-stubs + +pre-commit +setuptools +liccheck