From 66479609e3f494c3ef4ea13df518b91646703327 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Tue, 3 Dec 2024 12:59:04 -0800 Subject: [PATCH] fix #153 --- .pre-commit-config.yaml | 13 +++++++++++++ doc/source/changelog.rst | 1 + justfile | 9 +++++++-- pyproject.toml | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) 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..529cd40 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: + - repo: local + hooks: + - id: lint + name: Lint + entry: just lint + language: system + pass_filenames: false + - id: format + name: Format + entry: just format + language: system + pass_filenames: false diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index b16253d..c309374 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -7,6 +7,7 @@ Change Log v3.0.0 (202X-XX-XX) =================== +* Implemented `Add precommit hook to fix safe lint and format issues `_ * BREAKING `Remove name parameter from initialize()/callback(). `_ * Implemented `Run full test suite on mac osx `_ * Implemented `Convert check.sh to justfile `_ diff --git a/justfile b/justfile index 227a641..553fadd 100644 --- a/justfile +++ b/justfile @@ -12,10 +12,14 @@ init: poetry config --local virtualenvs.in-project true poetry run pip install --upgrade pip setuptools wheel +install-precommit: + poetry run pre-commit install + install *PACKAGES="Django": poetry env use python poetry lock poetry install -E rich + poetry run pre-commit install poetry run pip install -U {{ PACKAGES }} install-colorama: @@ -95,7 +99,7 @@ sort-imports: lint: sort-imports poetry run ruff check --fix -fix: format lint +fix: lint format check: check-lint check-format check-types check-package check-docs check-docs-links check-readme @@ -115,7 +119,8 @@ test: test-rich test-no-rich install-colorama test-cases +TESTS: poetry run pytest {{ TESTS }} -precommit: fix +precommit: + poetry run pre-commit coverage: poetry run coverage combine --keep *.coverage diff --git a/pyproject.toml b/pyproject.toml index 60302b4..d2d8c93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,6 +95,7 @@ graphviz = ">=0.20.3" pluggy = ">=1.5.0" pywinpty = { version = ">=2.0.14", markers = "sys_platform == 'win32'" } pytest-timeout = ">=2.3.1" +pre-commit = ">=4.0.1" [tool.poetry.extras] rich = ["rich"]