From 76ebf259417e61005ac24b21f8bc620d353c18dd Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 15 May 2024 20:59:58 +0100 Subject: [PATCH 01/23] Add the sample start of a pre-commit config --- .pre-commit-config.yaml | 10 ++++++++++ 1 file changed, 10 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 000000000..fd16ba2dc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files From 04ed6c5ece79dc4548f298119084242192215976 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 15 May 2024 21:04:16 +0100 Subject: [PATCH 02/23] Add custom-linters to the pre-commit setup --- .pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fd16ba2dc..848e8239a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,3 +8,10 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files +- repo: local + hooks: + - id: custom-linters + name: custom-linters + entry: pytest ci/custom_linters.py + language: system + pass_filenames: false From 9cd483e6c820b19c5fbb13a43b3231cdf14653b1 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 15 May 2024 21:18:07 +0100 Subject: [PATCH 03/23] Add pre-commit as a dependency --- .pre-commit-config.yaml | 20 ++++++++++++++++++++ LICENSE | 1 - docs/source/contributing.rst | 10 ++++++++-- lint.mk | 16 ---------------- pyproject.toml | 1 + 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 848e8239a..00af3a3f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,3 +15,23 @@ repos: entry: pytest ci/custom_linters.py language: system pass_filenames: false + - id: actionlint + name: actionlint + entry: actionlint + language: system + pass_filenames: false + - id: mypy + name: mypy + entry: mypy . + language: system + pass_filenames: false + - id: check-manifest + name: check-manifest + entry: check-manifest . + language: system + pass_filenames: false + - id: pyright + name: pyright + entry: pyright . + language: system + pass_filenames: false diff --git a/LICENSE b/LICENSE index 69f733fdf..ef26969f8 100644 --- a/LICENSE +++ b/LICENSE @@ -17,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index cb227290f..6227a554a 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -27,14 +27,20 @@ and on Ubuntu with ``apt``: apt-get install -y enchant +Install pre-commit hooks: + +.. prompt:: bash + + pre-commit install + Linting ------- -Run lint tools: +Run lint tools either by committing, or with: .. prompt:: bash - make lint + pre-commit run To fix some lint errors, run the following: diff --git a/lint.mk b/lint.mk index f7c96b63a..cc1079439 100644 --- a/lint.mk +++ b/lint.mk @@ -2,22 +2,6 @@ SHELL := /bin/bash -euxo pipefail -.PHONY: custom-linters -custom-linters: - pytest ci/custom_linters.py - -.PHONY: actionlint -actionlint: - actionlint - -.PHONY: mypy -mypy: - mypy . - -.PHONY: check-manifest -check-manifest: - check-manifest . - .PHONY: doc8 doc8: doc8 . diff --git a/pyproject.toml b/pyproject.toml index 4b8666ceb..6e8b231aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -327,6 +327,7 @@ dev = [ "vws-python==2024.2.19", "VWS-Test-Fixtures==2023.3.5", "vws-web-tools==2023.12.26", + "pre-commit==3.7.1", ] [project.urls] Documentation = "https://vws-python-mock.readthedocs.io" From f4dd0e9eae8656293c774e70b252ad3a7b52617a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 15 May 2024 21:18:31 +0100 Subject: [PATCH 04/23] Remove old Makefile command --- Makefile | 25 ------------------------- docs/source/contributing.rst | 6 ------ 2 files changed, 31 deletions(-) diff --git a/Makefile b/Makefile index f047bf528..e7c51da19 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ SHELL := /bin/bash -euxo pipefail -include lint.mk - # Treat Sphinx warnings as errors SPHINXOPTS := -W @@ -11,29 +9,6 @@ update-secrets: tar cvf secrets.tar ci_secrets/ gpg --yes --batch --passphrase=${PASSPHRASE_FOR_VUFORIA_SECRETS} --symmetric --cipher-algo AES256 secrets.tar -.PHONY: lint -lint: \ - actionlint \ - check-manifest \ - deptry \ - doc8 \ - linkcheck \ - mypy \ - pyproject-fmt \ - pyright \ - pyright-verifytypes \ - pyroma \ - ruff \ - spelling \ - vulture \ - pylint \ - custom-linters - -.PHONY: fix-lint -fix-lint: \ - fix-pyproject-fmt \ - fix-ruff - .PHONY: docs docs: make -C docs clean html SPHINXOPTS=$(SPHINXOPTS) diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 6227a554a..654043dfb 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -42,12 +42,6 @@ Run lint tools either by committing, or with: pre-commit run -To fix some lint errors, run the following: - -.. prompt:: bash - - make fix-lint - .. _Homebrew: https://brew.sh Running Tests From 2f949b80706cc094829e37f018db37e8abee6b28 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 15 May 2024 21:30:01 +0100 Subject: [PATCH 05/23] Move pyroma to pre-commit setup --- .pre-commit-config.yaml | 15 +++++++++++++++ lint.mk | 16 ---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 00af3a3f5..20f0b8063 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,3 +35,18 @@ repos: entry: pyright . language: system pass_filenames: false + - id: pyright-verifytypes + name: pyright-verifytypes + entry: pyright --verifytypes mock_vws + language: system + pass_filenames: false + - id: vulture + name: vulture + entry: vulture --min-confidence 100 --exclude .eggs . + language: system + pass_filenames: false + - id: pyroma + name: pyroma + entry: pyroma --min 10 . + language: system + pass_filenames: false diff --git a/lint.mk b/lint.mk index cc1079439..9516631e0 100644 --- a/lint.mk +++ b/lint.mk @@ -24,22 +24,6 @@ deptry: pylint: pylint *.py src/ tests/ docs/ ci/ -.PHONY: pyroma -pyroma: - pyroma --min 10 . - -.PHONY: pyright -pyright: - pyright . - -.PHONY: pyright-verifytypes -pyright-verifytypes: - pyright --verifytypes mock_vws - -.PHONY: vulture -vulture: - vulture --min-confidence 100 --exclude _vendor --exclude .eggs . - .PHONY: linkcheck linkcheck: $(MAKE) -C docs/ linkcheck SPHINXOPTS=$(SPHINXOPTS) From f96e5eb1a1b0ff5eda738a151e721500a9e314e4 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 15 May 2024 21:34:11 +0100 Subject: [PATCH 06/23] Format pyproject.toml --- .pre-commit-config.yaml | 1 + pyproject.toml | 2 +- src/mock_vws/resources/oops_error_occurred_response.html | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20f0b8063..ac28d00bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,3 +50,4 @@ repos: entry: pyroma --min 10 . language: system pass_filenames: false + files: pyproject.toml diff --git a/pyproject.toml b/pyproject.toml index 6e8b231aa..17c1b4c51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -294,6 +294,7 @@ dev = [ "freezegun==1.5.1", "furo==2024.5.6", "mypy==1.10.0", + "pre-commit==3.7.1", "pydocstyle==6.3", "pyenchant==3.2.2", "pylint==3.2.0", @@ -327,7 +328,6 @@ dev = [ "vws-python==2024.2.19", "VWS-Test-Fixtures==2023.3.5", "vws-web-tools==2023.12.26", - "pre-commit==3.7.1", ] [project.urls] Documentation = "https://vws-python-mock.readthedocs.io" diff --git a/src/mock_vws/resources/oops_error_occurred_response.html b/src/mock_vws/resources/oops_error_occurred_response.html index d844502ae..b5f4d39f5 100644 --- a/src/mock_vws/resources/oops_error_occurred_response.html +++ b/src/mock_vws/resources/oops_error_occurred_response.html @@ -2,7 +2,7 @@ Error - +